Click here to Skip to main content
15,887,332 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
ASP.NET
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

SQL
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)
Posted
Updated 29-Jan-24 21:53pm
v2
Comments
Dave Kreskowiak 25-Jan-24 10:33am    
You seem to have forgotten to ask a question. I don't think anyone has any idea what you're trying to do or what the problem is.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900