Link to home
Start Free TrialLog in
Avatar of NCSA SCADA
NCSA SCADAFlag for United States of America

asked on

bind grid to sqldatasource based on user selection

I have a grid that is bound to a sqldatasource.  I also have two additional sqldatasource's.
There is three radio buttons on the page, and when I user clicks one I want to rebind to the correct data source.. here is how I tried to do it, but did not work.. any help would be great (the rad's are set for auto postback)

 Protected Sub radShowAll_CheckedChanged(sender As Object, e As EventArgs) Handles radShowAll.CheckedChanged
        If radShowAll.Checked Then
            RadGrid1.DataSource = SqlAllOps
            RadGrid1.DataBind()
        End If
    End Sub

    Protected Sub radActive_CheckedChanged(sender As Object, e As EventArgs) Handles radActive.CheckedChanged
        If radActive.Checked Then
            RadGrid1.DataSource = SqlActiveOps
            RadGrid1.DataBind()
        End If

    End Sub

    Protected Sub radInactive_CheckedChanged(sender As Object, e As EventArgs) Handles radInactive.CheckedChanged
        If radInactive.Checked Then
            RadGrid1.DataSource = sqlInactiveOps
            RadGrid1.DataBind()
        End If

    End Sub

Open in new window

Avatar of Dale Burrell
Dale Burrell
Flag of New Zealand image

Firstly, why not use a single data source and pass the radio button value in as a parameter? That works out of the box.

Secondly if you do need multiple datasources, have you tried setting the DataSourceId property instead of the DataSource property?
ASKER CERTIFIED SOLUTION
Avatar of NCSA SCADA
NCSA SCADA
Flag of United States of America image

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 NCSA SCADA

ASKER

I figured out the issue myself