public partial class ControlCenter : System.Web.UI.Page
{
GetData GetConn = new GetData();
//protected PlaceHolder cardContainer;
protected Panel cardContainer;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable dt = this.BindMenuData();
DynamicMenuControlPopulation(dt, 0, null);
}
protected DataTable BindMenuData()
{
DataSet ds = new DataSet();
DataTable dt;
dt = new DataTable();
string s = "select * from cmsproject where ShowProject=1 order by SerialNo";
dt = GetConn.getdata(s);
ds.Tables.Add(dt);
var dv = ds.Tables[0].DefaultView;
//dv.RowFilter = "ProjectEntryID='" + parentmenuId + "'";
DataSet ds1 = new DataSet();
var newdt = dv.ToTable();
return newdt;
}
protected void DynamicMenuControlPopulation(DataTable newdt, int parentMenuId, MenuItem parentMenuItem)
{
string currentPage = Path.GetFileName(Request.Url.AbsolutePath);
foreach (DataRow row in newdt.Rows)
{
MenuItem menuItem = new MenuItem
{
Value = row["ProjectEntryID"].ToString(),
Text = row["ProjectName"].ToString(),
NavigateUrl = row["ProjectURL"].ToString().Trim(),
Selected = row["ProjectURL"].ToString().EndsWith(currentPage, StringComparison.CurrentCultureIgnoreCase)
};
Menu1.Items.Add(menuItem);
// Create a div element for the card
HtmlGenericControl cardDiv = new HtmlGenericControl("div");
cardDiv.Attributes["class"] = "card";
// Create a hyperlink for the card
HyperLink cardLink = new HyperLink
{
NavigateUrl = row["ProjectURL"].ToString().Trim(),
Text = row["ProjectName"].ToString()
};
// Add the hyperlink to the card div
cardDiv.Controls.Add(cardLink);
// Add the card div to the PlaceHolder
cardContainer.Controls.Add(cardDiv);
}
}
private DataTable GetDataFromSource()
{
// Implement a method to fetch data from your data source (e.g., database)
// For simplicity, this example returns a DataTable with dummy data
DataTable dt = new DataTable();
dt.Columns.Add("ProjectURL", typeof(string));
dt.Columns.Add("ProjectName", typeof(string));
dt.Rows.Add("http://120.120.120.167/cms/hrms/LoginPage.aspx", "Card HRMS");
dt.Rows.Add("http://120.120.120.167/cms/cpp/LoginPage.aspx", "Card CPP");
dt.Rows.Add("url3", "Card 3");
return dt;
}
}}
What I have tried:
make a dynamic card of http://120.120.120.167/cms/hrms/LoginPage.aspx page in controlcenter.aspx
CREATE TABLE [dbo].[CMSProject](
[ProjectEntryID] [int] IDENTITY(1,1) NOT NULL,
[ProjectName] [nvarchar](200) NOT NULL,
[ProjectURL] [nvarchar](200) NULL,
[ShowProject] [bit] NULL,
[SerialNo] [int] NULL,
[Description] [nvarchar](400) NULL)