Solved

no database linked Dataset seems to lose values

Posted on 2004-08-15
5
152 Views
Last Modified: 2010-04-07
Hi,

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.

Thanks.

James.

      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;
                  priceStream1.Instrument.Rows.Add(myRow);
                        
            }
            MessageBox.Show(priceStream1.GetXml(), "",MessageBoxButtons.OK,
                  MessageBoxIcon.Information,MessageBoxDefaultButton.Button1,
                  MessageBoxOptions.DefaultDesktopOnly);
      }
0
Comment
Question by:JAMES
  • 3
  • 2
5 Comments
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 11803573
Hi there,
is "WebGrid1" your DataSet. Well, I would say store it in a session and use it further.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconpassingservercontrolvaluesbetweenpages.asp

-Baan
0
 

Author Comment

by:JAMES
ID: 11803688
Baan,

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?

Thanks.

James.
0
 
LVL 18

Expert Comment

by:DotNetLover_Baan
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.

-Baan
0
 

Author Comment

by:JAMES
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?

Thanks.

0
 
LVL 18

Accepted Solution

by:
DotNetLover_Baan earned 500 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.
-Baan
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

863 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

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now