473,320 Members | 1,993 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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

Nov 21 '06 #1
0 1010

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Mark Olbert | last post by:
I ran into a situation this morning where the RowUpdating event of a GridView kept insisting there were no entries in either the OldValues or NewValues dictionaries. The GridView is bound to a...
5
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens...
4
by: Bishop | last post by:
I have a number of simple select queries that a user needs to be able to execute and display the data on the screen in a gridview. My thought was that I could use a Gridview set to dymanically...
5
by: GaryDean | last post by:
I have a GridView that works fine when I bind it to an ObjectDataSource at design time. But if I bind it at run time nothing happens. On a button click event I say... GridView1.DataSourceID =...
2
by: martin1 | last post by:
Hi, All, I has 2 gridview data like below and try to put data together into gridviewTotal or attach gridview2 to gridview1, these 2 gridview data structure same , just attach one column called...
3
by: nyhetsgrupper | last post by:
Hi everyone, In a datagrid the entire data is read but only the page you want is displayed to the user when you enable paging. Does the Gridview control works in the same way? So if you have...
3
by: jobs | last post by:
I've got a gridview that does not have a datasourceid assigned in the markup. I'd like to switch between two datasources in the codebehind. when I do switch, I first reset the the...
0
by: =?Utf-8?B?TGFkaXNsYXYgTXJua2E=?= | last post by:
Hello, I read some msdn and other articles about how does databinding among DataSource controls and FormView / GridView controls works but I still don't fully understand to this blackbox. I have...
4
by: Don Miller | last post by:
This is a repost of a reproducible problem/bug with GridView with dynamic SQL and binding. Is there a better ASP.NET newsgroup I should post to where MS techs or MVPs take an interest in such...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.