DataGrid Won't come back(2)

T

Tina

This message refers to the one I left an hour ago. It's another way to ask
a question that will help me solve my problem.

Below is a working ASPX program. It has two buttons and a DataGrid named dg
on it. There is a dataadapter and an associated typed dataset that is the
source to the datagrid. All a very typical program. When button one is
pushed the grid gets filled. When button 2 is pushed dg IS STILL
THERE(thats good of course). Why is it still there? Each time a form is
used it is destroyed. What restores dg? There is no code in the " web form
designer generated code" that restores it. How does the dg object get
rebuilt?

thanks,
T

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
daCustLogin.Fill(DsCustlogin1)
dg.DataBind()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim dgItem As DataGridItem

For Each dgItem In dg.Items
Dim mystring As String
mystring = dgItem.Cells(0).Text

Next
End Sub
 
T

Terry Olsen

I believe that's the work of the VIEWSTATE hidden control. When looking at
an aspx page, view the source of that page and you'll see

<input type="hidden" name="__VIEWSTATE" value=

followed by a bunch of garbage. That isn't really garbage, it's the page's
format and data. When you click the button, the VIEWSTATE gets posted back
to the server so that it can be "re-rendered" back to the client with
whatever changes are made by the button click event.

Of course, I could be totally wrong, in which I sheepishly apologize. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top