Link to home
Start Free TrialLog in
Avatar of dc900
dc900

asked on

Populating GridView from a dropdown list.

I have a GridView where I configured the SmartTag connection and SQL statement to use the value specified in the dropdown list control.  The query test worked correctly.  I added a data bind for the grid when the value in the dropdown changes, but this does not work and my grid does not appear.  Any thoughts on what might be wrong?

Protected Sub ddlSite_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlSite.SelectedIndexChanged
        gvSiteDocuments.DataBind()
    End Sub

I am looking for some guidance or sample code that will help me complete this.  Any information will
be greatly appreciated.  Thanks.  DC900

My Environment
    Windows XP Pro
    Visual Studio 2005 & VB.NET
    SQL Server 2000
Avatar of jjaqua
jjaqua
Flag of United States of America image

How are you populating the GridView i.e. what is the datasource? I would think you would have your drop down list change something in the query used for the GridViews datasource. In that case you would have to set the new data source and bind to the GridView when the drop down list changes.

        Me.GridView1.DataSource = NewDataSource(New Query based on selected drop down value)
        Me.GridView1.DataBind()
ASKER CERTIFIED SOLUTION
Avatar of BoggyBayouBoy
BoggyBayouBoy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BoggyBayouBoy
BoggyBayouBoy

Or... you can go to the ASP.NET Quickstart Tutorial Site and you'll find an example for doing just what you're asking.  

http://www.asp.net/QuickStart/aspnet/

look for the example called "VB Filter By DropDownList".  You'll find it under "Performing Data Access > Filtering Data"