I'm using an Access DB and coding a web form that should display a datagrid and a drop down list. They both should use the same table in the db for their source. Currently the datagrid is populated correctly by a SQL query and a bit of code. Dim strConn As
String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source ...etc Dim NewCat As String NewCat = Session("RxCat") DIM MySQL As String = "Select * from Rolodex where RxCat='"&NewCat &" ' " Dim MyConn As New Oledb.OleDbConnection(strConn) Dim ds As DataSet = New
DataSet () Dim Cmd As New OleDb.OleDbDataAdapter(MySQL, MyConn) Cmd.Fill(ds, "Rolodex") MyDataGrid.DataSource=ds.Tables("Rolodex").DefaultView MyDataGrid.DataBind() DropDownList1.Items.Insert(0, New ListItem("--Please Select a Catagory ---") DropDownList1.SelectedIndex
= 0 How do I select a particular Column in the dataset to populate the DDL? I thought about using a table and was able to populate the datatable but ran into the same question. Anyone? Thanks, Joe
Dim dv As New DataView dv.Table = ds.Tables("Rolodex") dv.Sort = "Text_Column" DropDownList1.DataSource = dvLoad DropDownList1.DataTextField = "Text_Column" DropDownList1.DataValueField = "Key_Column" DropDownList1.DataBind() This is my suggestion.
JSweeney20
Member
95 Points
19 Posts
Binding a DropDown List and DataGrid to the same source
Jul 10, 2003 08:38 PM|LINK
superbananam...
Member
307 Points
62 Posts
Use a dataview.
Jul 10, 2003 09:17 PM|LINK
JSweeney20
Member
95 Points
19 Posts
Re: Use a dataview.
Aug 06, 2003 03:15 PM|LINK