Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing DataGrid's DataSource based on Radio Button

Status
Not open for further replies.

jmikow

Programmer
Mar 27, 2003
114
US
I am currently trying to get a DataGrid's datasource to change based on which item is selected in a radio button.

Currently I have the code:

Code:
        Select Case rblETAVDataSet.SelectedItem.Value
            Case "O"
                dgrdETALNames.DataSource = DsOriginalData
                dgrdETALNames.ShowFooter = False
            Case "N"
                dgrdETALNames.DataSource = DsWorkingData
                dgrdETALNames.ShowFooter = True
        End Select
        dgrdETALNames.DataBind()

I have it set in the ItemDataBound event to make the datagrid read-only if the selected value is "O". That works, but it sill displays the data from the working dataset.

It doesn't appear to change datasources when I change the selected value. Both DataSets are derived from the same typed dataset.

I have the dataset specified through the design-time functionality and not through the runtime. Would that cause it to not be overwritable during runtime?

Is there something that I am missing that would make this work?

Thanks,

Josh
 
Call dgrdETALNames.DataBind

Not sure if the ondatabind event is dgrdETALNames, but if it is you may need to do that in the page_prerender event.
 
Remove the datasource in the properties window and see if it works. I think maybe that is causing your problem.

Jim
 
I tried taking out the setting of datasource during design time and setting it through the runtime and that appears to have fixed the problem.

Now I just need to set the datasource before every databind() command that I send to make sure it uses the correct dataset.

Thanks for your assistance.

Josh
 
Glad you got it working. The extra line of code should be no big deal...

Jim :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top