Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0
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
 
 
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 28-Jan-13 6:52am
Edited 28-Jan-13 7:11am
v2
Comments
Sergey Alexandrovich Kryukov at 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 at 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 at 31-Jan-13 15:15pm
   
Too bad I can't upvote this.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Please refer links:
1) Link1
2) Link2
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,127
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 30 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100