473,503 Members | 13,381 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cannot refer to data table

In the Page_Load event of web form, I create a DataSet and fill up by a
DataAdapter. Then I can retrieve data by the following command :
ds1.Tables(0).Rows(0).Item("accno")
However, when I issue the same command in DataGrid1_SelectedIndexChanged,
error occurs, Tables(0) cannot be reference. How can I fix it? Thanks.
Nov 18 '05 #1
3 1022
Your dataset will need to get repopulated on postback if you want to access
it (or store it in a viewstate *shrug*)...

Karl

"Joe Au" <jo***@livingfaith.org.hk> wrote in message
news:OE**************@tk2msftngp13.phx.gbl...
In the Page_Load event of web form, I create a DataSet and fill up by a
DataAdapter. Then I can retrieve data by the following command :
ds1.Tables(0).Rows(0).Item("accno")
However, when I issue the same command in DataGrid1_SelectedIndexChanged,
error occurs, Tables(0) cannot be reference. How can I fix it? Thanks.

Nov 18 '05 #2
Where do you store the dataset?
How do you reference it from within the event?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Joe Au" <jo***@livingfaith.org.hk> wrote in message
news:OE**************@tk2msftngp13.phx.gbl...
In the Page_Load event of web form, I create a DataSet and fill up by a
DataAdapter. Then I can retrieve data by the following command :
ds1.Tables(0).Rows(0).Item("accno")
However, when I issue the same command in DataGrid1_SelectedIndexChanged,
error occurs, Tables(0) cannot be reference. How can I fix it? Thanks.

Nov 18 '05 #3


Thanks to Karl and Miha. Karl is right. I populate the DataSet only when
the web form is first loaded.
Joe.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #4

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

Similar topics

3
12975
by: Drew | last post by:
I am trying to use Bulk Insert for a user that is not sysadmin. I have already set up the user as a member of "bulkadmin". When I run the following script: DECLARE @SQL VARCHAR(1000) CREATE...
2
36240
by: Ralph Smith | last post by:
I'm having trouble copying a database to another machine. Here are the two table's in ths database and the sql commands: DROP TABLE IF EXISTS `clients`; CREATE TABLE `clients` ( `client_id`...
11
2512
by: RdR | last post by:
Hi, I am using Q Replication, I need to set to logging to capture changes on a table but the table has more than 18 characters for the name, I looked at the docs, it mentioned that table names...
0
400
by: Matthew Louden | last post by:
I am trying to implement the sort event in data grid. I set the data grid's AllowSorting property = True. I implement the following code that should be the event will fire when the user click any...
7
3822
by: Wayne Brantley | last post by:
I have found what appears to be an error in streaming with Datasets. It causes an error of 'Cannot find relation 0' when recreating the dataset from a stream. Here is how you reproduce it. ...
9
5040
by: tomblower | last post by:
Access 2000 fully updated Three PCs manage data held on a server. They each have a front-end mdb file linked to tables on the server and on each PC. A problem has arisen over the following line...
6
1961
by: RAM | last post by:
Hello, Could you help me please to solve the prblem with connecting to SQL Server from .NET development environment? I have the following error: "An error has occured while establishing a...
3
3934
by: epearce301 | last post by:
Hi, I have table1 and table2, both are linked, and a query has been run. I created forms that use both just the tables, and then another one using just the query. All of the information is there,...
1
2447
by: teenagelcruise | last post by:
hi, i have a problem with my code which is i cannot update and addnew data into the database but i can delete the data.plz give me an idea.this is my code that i wrote. <html> <head> <meta...
0
7213
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4698
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
406
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.