Click here to Skip to main content
15,893,487 members

Trying to use drop down list as filter

Revision 2
Hello, Thanks for looking at my post. I am trying to use a dropdown list to act as a filter then display the values in a gridview. I looked all over the internet and found several ways. I have not been able to get any of them to work. Here is the code I am using. I am getting an error "Fill: SelectCommand.Connection property has not been initialized."
VB
Dim con As New SqlConnection(my connection to the database)
Dim command As New SqlCommand("select * from grades where test = "      Convert.ToString(Me.DropDownList2.SelectedValue))
Dim dataAadpter As New SqlDataAdapter(command)
con.Open()
Dim ds As New DataSet()
dataAadpter.Fill(ds)
GridView2.DataSource = ds
GridView2.DataBind()
GridView2.Visible = True
con.Close()

Thank-you for your help,

D
Posted 29-Jan-13 8:52am by D-Bar.
Tags: , ,