How to add items in listbox from database
-
i tried to add the items in listbox from database but it adds only one record from database
-
i tried to add the items in listbox from database but it adds only one record from database
-
i tried to add the items in listbox from database but it adds only one record from database
Try to use this two properties: DataValueField and DataTextField. e.g.
//SOURCE_FROM_DB -> The method or object or ... whatever ... that has the items. myListBox.DataSouce = SOURCE_FROM_DB; //VALUE_COLUMN_NAME -> The column name of the DataSource that represents the VALUE of the item. myListBox.DataValueField = "VALUE_COLUMN_NAME"; //TEXT_COLUMN_NAME -> The column name of the DataSource that represents the TEXT of the item. myListBox.DataTextField = "TEXT_COLUMN_NAME"; myListBox.DataBind();