Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is a row added to session datatable disappearing on refresh of page?
    text
    copied!<p>I have set up a class as a facade to access the session variables for my app. In this app I store an entire dataset for a particular employer as a session variable.</p> <p>Within one of the sub pages I have a button that adds a row to an existing table stored in that dataset.</p> <pre><code> Dim curRow As Data.DataRow = mySession.tWorksiteOtherMeasures.NewRow() curRow("lngWorksiteID") = getSelectedWorksiteID(getSelectedSiteID()) curRow("strMeasure") = "" curRow("lngStatusID") = -1 curRow("lngPoints") = -1 mySession.tWorksiteOtherMeasures.Rows.Add(curRow) </code></pre> <p>The class is accessing the table using this:</p> <pre><code>Public Shared ReadOnly Property tWorksiteOtherMeasures() As Data.DataTable Get Return dsEmployer.Tables(TWORKSITEOTHERMEASURES_IDX) End Get End Property Public Shared Property dsEmployer() As Data.DataSet Get Return CType(HttpContext.Current.Session(DSEMPLOYER_IDX), Data.DataSet) End Get Set(ByVal value As Data.DataSet) HttpContext.Current.Session(DSEMPLOYER_IDX) = value End Set End Property </code></pre> <p>When in the code to add the row the row count increments and the row exists. Once out of that scope the page refreshes due to the button being contained in an updatePanel. When that happens and I click the add button again the row counts for that item reset to 0 and 1 after the code runs. The previous added row is gone.</p> <p>What am I missing? Feel free to post examples in other languages if you wish, I just happen to be using VB.NET at work. :)</p> <p>Here is how the Dataset is assigned from the web service:</p> <pre><code>Public Shared Sub loadDSEmployer(ByVal strUserId As String) Dim myService As New someservice.service mySession.dsEmployer = myService.GetEmployerAndSites(strUserId, isInternal) End Sub </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload