Gridview with changing Datasources in code - some things don't work

J

jobs

Is there a correct way to change the datasourceId of a gridview in
codebehind so that things like sorting, paging and deleting actually
work?

Or will have have to have one one to one relationship between
datasources and gridviews?

when I switch datasources - deletes don't happen and I get erros like
this when I try to page or sort:

The GridView 'RateGridView' fired event Sorting which wasn't handled.


Here's how I switch:

RateGridView.DataSourceID = Nothing
RateGridView.DataSource = Nothing
ChargeGridView.DataSourceID = Nothing
ChargeGridView.DataSource = Nothing
If StatusLabel.Text = "" Then
If Hcheck.Checked Then
RateGridView.DataSource = RateGridSourceAll
ChargeGridView.DataSource = ChargeGridSourceAll
Else
RateGridView.DataSource = RateGridSource
ChargeGridView.DataSource = ChargeGridSource
End If
ChargeGridView.DataBind()
RateGridView.DataBind()
End If

Else
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top