.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

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -