DataBound WebForms DataSet goes Empty

  • Thread starter Thread starter JS
  • Start date Start date
J

JS

Having a little trouble getting at my data after the webform I'm using is
submitted. Perhaps this is better posted to web forms, but its my ADO
implementation that seems to be the problem. I'm using a DataSet control
on a form that I bind the form's controls to. But when I check that DataSet
at the server after a button click on the form, its completely empty, no
DataTables in it at all.

Any insights would greatly be appreciated.


<form runat=server>
<asp:TextBox id="txtTitle" runat="server" Text='<%#
DataBinder.Eval(DsArticles1, "Tables
.DefaultView.[0].Title") %>'>
</asp:TextBox>
</form>


Protected WithEvents DsArticles1 As News.DSArticles 'DS object on web
form

Sub Page_Load()
Dim oArticles As Articles.Articles
oArticles = New Articles.Articles() 'Custom Data Retrieval
Object - returns a DS

Dim oDS As DataSet
oDS = oArticles.GetArticles("WHERE ID = '" & strID & "'")

DsArticles1.Merge(oDS)

DataBind()

Response.Write(DsArticles1.Tables("Table").Rows.Count)

'**** RETURNS 1 ****
' Works great, Form shows the data from this row per data bound
control as above txtTitle

End Sub

Sub butSave_Click
System.Diagnostics.Trace.Write(DsArticles1.Tables("Table").Rows.Count)
' **** NOW RETURNS 0 ****
' In fact, now there are no datatables in this dataset at all.

System.Diagnostics.Trace.Write(DsArticles1.GetXml)
' **** RETURNS: '<DSArticles
xmlns=" http://tempuri.org/Schema_Articles.xsd " />' ****

System.Diagnostics.Trace.Write(txtTitle.text)
' **** RETURNS PROPER FIELD VALUE ****

End Sub
 
Hello JS
Web Model does not have any State . So It is per request , It processes
your request and thats it , every thing is gone . So if you want the
Dataset you have to store that in a Session or View state Object .

Here you can Just do some thing Like this in VB
session("Dataset") = yourDataset

To retreive it
YourDataset = Session("Dataset")

See Session Documenation in MSDN for more examples
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vbcode/h
tml/vbtskcodeexamplesavingsessionstate.asp

Thanks
Sunder
VB.Net
 
Back
Top