Global variable.

  • Thread starter Thread starter Phoebe.
  • Start date Start date
P

Phoebe.

Hi, Good Day!

I need to create a variable that it's value can be carry across within a
form.

I've created some above the "web form designer generated code" but it seems
not working.

It reset back to nothing when i click on a button.

Can someone help?
Thanks in advanced.

rgds,
Phoebe
 
Your variables get reset when you click a button because the clicking of
that button causes the entire form to be re-created (and therefore reset).

In ASP.NET, by the time the client has received the web page, the server has
completed its processing of that page and unloaded it from memory. Each and
every time the page is requested again (which clicking a button would
cause), the page is created from scratch all over again.

The variables you created, are available anywhere in the programming of the
page, but only while the page is being processed.
 
Thanks Carno.

My situation is i have a edit in my datagrid and this trigger
Sub EditRec(Byval objsrc as object, byval objargs as
datagridcommandeventargs)
...
End Sub

I have a Update button which trigger
Sub UpdateRecord(byval sender as system.object, byval e as system.eventargs)
...
End Sub

I need to capture my previous record from Sub EditRec and compare them in
Sub UpdateRecord.

Any idea on how it works?
Thanks in advanced.

rgds,
Phoebe.
 
In the DataGrid's EditCommand event handler use the eventArgs argument to
determine what row was edited (e.item?).
 
Yes, and the only way to do that is to know what record was just edited (see
my last post). Once you know what row of the grid was edited, you can use
FindControl to grab the data.
 
Thanks again, Scott.

Scott M. said:
Yes, and the only way to do that is to know what record was just edited (see
my last post). Once you know what row of the grid was edited, you can use
FindControl to grab the data.
 
Back
Top