Click here to Skip to main content
15,662,484 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a dataset which has declare globally
I have a combobox.
when I click on combo box it fetch the data and set into the dataset..
I have a button
When i click on the button I need the value of dataset.
I am writing
DataRow[] dr = dsAdv.Tables[0].Select("Advisor_Id=" + cmbAdvisorNameCode.SelectedValue.ToString());

//Here dsAdv is my dataset which declare globally

but when I click button then it showing error, because data could not fetch
It showing Table[0] has no value.

please help me how to solve this problem.
It's urgent.
other wise please tell me woh can I use global dataset in the same page.

Updated 10-Nov-11 1:50am
Amol_27101982, India 10-Nov-11 23:58pm    
Have you got any solution ??

One way is you can store dataset to Viewstate/Session.
Share this answer
JBSAHU 10-Nov-11 8:10am    
but when i am using session or viewstateI am not getting the properties tables[0],so how can i write my query over there.
First thing is that I don't like people who declare dataset globally.
Any way as you have done that it becomes very important where you are initializing that dataset (dsAdv = new dataset();).

One chance is that on every post back it might initializing your dataset.

Is it really necessary to declare dataset globally ???

To avoid all these things do following:

1. Don't declare any dataset globally.
2. don't do anything on the index change of combo box.
3. when you click on the button, create one instance of dataset, read what is selected in the combobox, fire a query accordingly and fill the dataset.
4. This way you will never face any unexpected problem.

Hope this will help you.

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900