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

Discussion in 'ASP .Net' started by jobs, Nov 21, 2006.

  1. jobs

    jobs Guest

    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
    jobs, Nov 21, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?=

    vs2005 publish website doing bad things, bad things

    =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?=, Oct 25, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    596
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Oct 25, 2006
  2. jobs
    Replies:
    3
    Views:
    625
  3. =?Utf-8?B?TGFkaXNsYXYgTXJua2E=?=

    FormView and GridView with DataSources

    =?Utf-8?B?TGFkaXNsYXYgTXJua2E=?=, Feb 1, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    454
    =?Utf-8?B?TGFkaXNsYXYgTXJua2E=?=
    Feb 1, 2007
  4. Shanksluvsuall
    Replies:
    0
    Views:
    371
    Shanksluvsuall
    Mar 14, 2008
  5. Xeno Campanoli
    Replies:
    3
    Views:
    105
    Xeno Campanoli
    Jun 15, 2007
Loading...

Share This Page