.net - Retrieving value from database and set dropdown selected item -


i having hard time retrieve value database columns , assign value dropdownlist.selecteditem.text. have query like

select [productname]+' '+ '('+[category]+')'  productnamecategory products 

i want assign query result drop down list. this

dropdownlist.selecteditem.text=productnamecategory 

can call displaymember on ddl?

the below syntax windows app. combobox set ddl. need tell value binded.

        try //try block opening, querying , displaying pulled data         {             sqlconnection sqlconn = new sqlconnection("connstring"); //connection string             sqlconn.open();             using (sqldataadapter dataadapter = new sqldataadapter("select * test_names", sqlconn))             {                 var table = new datatable();                 a.fill(table);                            combobox1.datasource = t;                        combobox1.displaymember = "firstname"; //name of column/displayname                 combobox1.valuemember = "firstname"; //name of column/value                        }                                              }         sqlconn.close(); //close conn         catch (exception ex)         {         //handle errors         } //end try catch sql operations 

Comments

Popular posts from this blog

java - How to Configure JAXRS and Spring With Annotations -

visual studio - TFS will not accept changes I've made to a Java project -

php - Create image in codeigniter on the fly -