combo box
-
hi all, how to add data from database table to the combobox, where i want to read a certain feild and when selected an other feild would be written in somewhere else
Which technology are you using: Windows Forms, ASP.net, WPF or other?
-
hi all, how to add data from database table to the combobox, where i want to read a certain feild and when selected an other feild would be written in somewhere else
costavo wrote:
how to add data from database table to the combobox, where i want to read a certain feild and when selected an other feild would be written in somewhere else
SqlConnection dbConn = new SqlConnection ("connectionstring"); dbConn.Open (); SqlDataAdapter da = new SqlDataAdapter ("SELECT town FROM Table", dbConn); da.Fill (ds); DropDownList1.DataSource = ds.Table[0]; DropDownList1.DataBind ();
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)
-
costavo wrote:
how to add data from database table to the combobox, where i want to read a certain feild and when selected an other feild would be written in somewhere else
SqlConnection dbConn = new SqlConnection ("connectionstring"); dbConn.Open (); SqlDataAdapter da = new SqlDataAdapter ("SELECT town FROM Table", dbConn); da.Fill (ds); DropDownList1.DataSource = ds.Table[0]; DropDownList1.DataBind ();
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)
You can also check my reply here[^]. Hope it helps.
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)
-
hi all, how to add data from database table to the combobox, where i want to read a certain feild and when selected an other feild would be written in somewhere else
in addition to the reply of Micheal sync u also have to set the display member and value member properties. set the display member to the field which u want to show. and set the value member to the field which u want to display at some place else. and on selectedindexchanged event set show your selected value ...
-
in addition to the reply of Micheal sync u also have to set the display member and value member properties. set the display member to the field which u want to show. and set the value member to the field which u want to display at some place else. and on selectedindexchanged event set show your selected value ...
-
costavo wrote:
please would u give a code example
As I replied here,[^]
SqlConnection dbConn = new SqlConnection(connectionString); dbConn.Open(); SqlDataAdapter da = new SqlDataAdapter("SELECT town,postal FROM table1", dbConn); DataSet ds = new DataSet(); da.Fill(ds); dbConn.Close(); DropDownList1.DataSource = ds.Tables[0]; **DropDownList1.DataTextField = "town"; DropDownList1.DataValueField = "postalcode";** DropDownList1.DataBind();
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)