cannot refer to data table

J

Joe Au

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.
 
K

Karl

Your dataset will need to get repopulated on postback if you want to access
it (or store it in a viewstate *shrug*)...

Karl
 
M

Miha Markic [MVP C#]

Where do you store the dataset?
How do you reference it from within the event?
 
J

Joe Au

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

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,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top