help combobox
-
may i know the way to fill the data from database to the combobox? for datagrid the code is datagridname.setDataBinding(dsStu, "StuTable") then how about the combobox?
Create & fill a dataset object then use the combobox's DataSource and DisplayMember properties display data from the dataset.
-
Create & fill a dataset object then use the combobox's DataSource and DisplayMember properties display data from the dataset.
-
may i know the way to fill the data from database to the combobox? for datagrid the code is datagridname.setDataBinding(dsStu, "StuTable") then how about the combobox?
Here is one way of binding data in combo box: In code behind: Dim ds As New DataSet ds = class_Ratetype.ComboRateDisplay() Dim dvs As New DataView(ds.Tables(0)) If dvs.Count > 0 Then Me.ComboRoomType.DataSource = dvs Me.ComboRoomType.DisplayMember = "Roomtype" Me.ComboRoomType.ValueMember = "Roomtype_Id" End If End Sub Class file content for this: Public Function ComboRateDisplay() As DataSet Dim constr As String = SqlHelper.GetConnectionString() Dim conn As New SqlConnection(constr) Dim cmdSQL As New SqlCommand("SP_COMBORATEDISPLAY", conn) Dim da As New SqlDataAdapter Dim ds As New DataSet Dim dv As New DataView cmdSQL.CommandType = CommandType.StoredProcedure conn.Open() da.SelectCommand = cmdSQL da.Fill(ds, "TBL_Roomtype") ComboRateDisplay = ds.Copy da.Dispose() If (Not conn Is Nothing) Then conn.Close() conn.Dispose() End If GC.Collect() End Function For ur reference: class_Ratetype ---> object for class file ComboRoomType ----> combobox name Roomtype ----> Display member Roomtype_Id ----> Value member SP_COMBORATEDISPLAY --> Stored procedure TBL_Roomtype ----> Table name Janani
-
may i know the way to fill the data from database to the combobox? for datagrid the code is datagridname.setDataBinding(dsStu, "StuTable") then how about the combobox?