Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
i am working for cms in which the all the pages are created dynamically now the thing is that i have get back all the title from database to the menu strip, now when i click on the page i..e title it has to get content from database where all this contain in the one table of the database i..e how i can redirect to that page dynamically.for this i have written a for it

C#
public partial class menu : System.Web.UI.Page
{
   
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            PopulateMenu();

    }
    DataSet GetMenuData()
    {
        SqlConnection con = new SqlConnection("Data Source=localhost;Initial Catalog=newdata23;User ID=sa;Password=123");
        SqlDataAdapter dadCats = new SqlDataAdapter("SELECT cms_title FROM cms", con);
        //SqlDataAdapter dadProducts = new SqlDataAdapter("SELECT * FROM Products", con);
        DataSet dst = new DataSet();
        dadCats.Fill(dst, "cms");
        
        return dst;
    }
    public void PopulateMenu()
    {
        DataSet dst = GetMenuData();
        foreach (DataRow masterRow in dst.Tables["cms"].Rows)
        {
            MenuItem masterItem = new MenuItem((string)masterRow["cms_title"]);
            Menu1.Items.Add(masterItem);

        }
    }
}
Posted
Updated 28-Jan-13 6:11am
v2
Comments
Sergey Alexandrovich Kryukov 28-Jan-13 19:25pm    
At least put a question mark after your question — I almost deleted this post. Please understand: we are haunted by a great number of non-questions, so, if you don't show your question very clearly, there is a chance of accidental removal of it, so you would need to do it again.
—SA
Jibesh 28-Jan-13 20:13pm    
In Addition to Sergeys comment, do not use text word use proper words and statements. not every one here likes to read text words.
DanielSheets 31-Jan-13 15:15pm    
Too bad I can't upvote this.

1 solution

Please refer links:
1) Link1
2) Link2
 
Share this answer
 

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