Click here to Skip to main content
15,903,854 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i bind the menu control form database(sql server) table through xml datasource.but when i select the menu item I need to get that menu item value and display in the page.how to do like this

Please share the solutions.
Posted
Comments
CodeBlack 22-Aug-13 1:11am    
Can you please update your question with ASPX and CS code sample ?

1 solution

C#
public static void dropdownbind1(string tbl, string field, DropDownList ddl, string datatext, string datatvale)
   {
       ddl.Items.Clear();
       str = "select distinct " + field + " from " + tbl + ""
       cmd = new MySqlCommand(str, Classmysql.con);
       dtp = new MySqlDataAdapter(cmd);
       ds = new DataSet();
       dtp.Fill(ds);
       if (ds.Tables[0].Rows.Count > 0)
       {
           ddl.DataSource = ds;
           ddl.DataTextField = datatext;
           ddl.DataValueField = datatvale;
           ddl.DataBind();
           ddl.Items.Insert(0, "SELECT");
       }
       else
       {
           ddl.Items.Insert(0, "no details");

       }
here is the example.it is general method.

   }
 
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