For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET > September 2005 > DataGrid Won't come back(2)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author DataGrid Won't come back(2)
Tina

2005-09-29, 7:01 pm

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


Terry Olsen

2005-09-30, 8:01 am

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. :)

"Tina" <tinamseaburn@nospammeexcite.com> wrote in message
news:eVazQBVxFHA.3856@tk2msftngp13.phx.gbl...
> 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
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com