Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


no database linked Dataset seems to lose values

Posted on 2004-08-15
Medium Priority
Last Modified: 2010-04-07

I have a strongly typed non-database connected local dataset called "priceStream1".  I am iterating through a grid which adds rows to the "Instrument" table within this dataset (see below).  

At the end of this loop, for debug reasons, I am displaying the table data in XML of the records added - in my instance this is two and all is fine so far.

However, when I then try to inspect the dataset from another procedure within the same page (in my example I am assigning this new messageBox function which should display the data again to a simple server side button) the record count of the dataset is zero and therefore the XML statement is empty (apart from the default stuff).

It looks like some sort of scope issue but the priceStream1 dataset should be visible throughout my class.

Any help would greatly be appreciated.



      private void Button2_Click(object sender, System.EventArgs e)
            for (int i = 0; i <= WebGrid1.RootTable.Rows.Count - 1; i++)
                  PriceStream.InstrumentRow myRow = priceStream1.Instrument.NewInstrumentRow();
                  myRow.Code = WebGrid1.RootTable.Rows[i].Cells[1].Text;
                  myRow.Price = Convert.ToDouble(strPrice);
                  myRow.Col = 0;
                  myRow.Row = i;
                  myRow.RequestID = i;
            MessageBox.Show(priceStream1.GetXml(), "",MessageBoxButtons.OK,
Question by:JAMES
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 18

Expert Comment

ID: 11803573
Hi there,
is "WebGrid1" your DataSet. Well, I would say store it in a session and use it further.


Author Comment

ID: 11803688

WebGrid1 is a databound grid which is linked to another bound dataset.  I iterate through this grid on startup to populate my dataset called priceStream1.

I am not trying to see this data in another web page, I just want to retrieve it in the same page.  

Would you still consider it a session issue?


LVL 18

Expert Comment

ID: 11804397
ok... I got it now... sorry about that.
Try to insert a strongly typed row just to see if you can insert into the "Instrument" table. Don't use the loop... for testing.


Author Comment

ID: 11804614
The instrument table is being updated no problem - I show the XML from the datagrid after all the updates have been done and all is fine - they are all there...  It's only when I try to retrieve that data (after a button click elsewhere but on the same page) that it's gone.

I think you are correct when you say I have to save the data in a session object (or viewstate) and then repopulate the dataset after postback!

Would you agree?


LVL 18

Accepted Solution

DotNetLover_Baan earned 2000 total points
ID: 11804732
hmm, ya.. since you are clicking on a button to display the data, this is as good as a different page, but with Page.IsPostBack = true. Go ahead and use session... that should work.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question