p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

aspx thread: Editing Data in Datagrid


Message #1 by "Hugh McLaughlin" <hugh@k...> on Thu, 11 Jul 2002 16:15:04
Hello Everyone and thanks for your help in advance.  I am working on an 
application that display a list of employee names within a datagrid.  Upon 
clicking an Edit button, I want to be able to transfer the user to another 
screen (panel) within the same ASPX page for editing.  The form contains 
employee details and is quite lengthy, thus it does not work well with 
inline editing.  Using the datakey attribute, I have been able to figure 
out how to send the EmployeeID to a delete function for deletion and the 
add function is straightforward.  But I am running into problems with 
performing the edit.  Ideally, since a query has already been performed, I 
would like to work with the same disconnected dataset and populate the the 
panel fields with the appropraite data - then allow the user to makes 
edits and save.  I cannot seem to figure out how to reference each of the 
fields for the particular data row.  I can pass the EmployeeID and simply 
requery the databse, but this seems like a waste of resources.  All of the 
examples that I have found use inline editing, which I simply think won't 
work here.  Any ehlp would be greatly appreciated.  Thanks.
Message #2 by "Carole D. Sullivan" <carolesullivan@e...> on Fri, 12 Jul 2002 21:03:47
I am still new to .net, but unless you do something to persist your 
dataset, I don't think it is there anymore.  I had a onclick event and 
could not figure out why it could not see my data.  Showing the 
recordcount for my dataset proved to me that since I gone from one event 
to another the data was no longer there.  Check you dataset recordcount:

Dim rowCount As Integer = DsOperScreens1.Tables(0).Rows.Count
Response.Write rowCount

Sorry I can't more, but this might get you moving again.

Surely someone out there can provide more info.....


Carole

> Hello Everyone and thanks for your help in advance.  I am working on an 
a> pplication that display a list of employee names within a datagrid.  
Upon 
c> licking an Edit button, I want to be able to transfer the user to 
another 
s> creen (panel) within the same ASPX page for editing.  The form contains 
e> mployee details and is quite lengthy, thus it does not work well with 
i> nline editing.  Using the datakey attribute, I have been able to figure 
o> ut how to send the EmployeeID to a delete function for deletion and the 
a> dd function is straightforward.  But I am running into problems with 
p> erforming the edit.  Ideally, since a query has already been performed, 
I 
w> ould like to work with the same disconnected dataset and populate the 
the 
p> anel fields with the appropraite data - then allow the user to makes 
e> dits and save.  I cannot seem to figure out how to reference each of 
the 
f> ields for the particular data row.  I can pass the EmployeeID and 
simply 
r> equery the databse, but this seems like a waste of resources.  All of 
the 
e> xamples that I have found use inline editing, which I simply think 
won't 
w> ork here.  Any ehlp would be greatly appreciated.  Thanks.
Message #3 by "Mike Amundsen" <mike@a...> on Fri, 12 Jul 2002 16:53:06 -0400
Remember that web pages are stateless - they do not retain any data in
memory between refreshes. 

Think about it like this: 
- browser calls the page at the server
- server loads the page into memory
- server executes any code in the page ( a click event)
- server creates new HTML to send to client and sends that
- server removes the page from memory

any data pulled during the execution of the page is not automatically
stored in memory on the server or the client.

However you *can* persist data using:

- cookies (sent back and forth in the header requests between client and
server)
- hidden HTML input fields (sent in the body of the page with each call
- session state (stored in server memory using a cookie to identify the
memory block to the client browser

one way to store a dataset between calls is to insert it into a session
var each time  before unloading the page. While this is possible, you
could eat up a lot of memory on the server for this - esp. if you have
lots of users reading the same data and storing their own copies on the
web server.  100 users accessing the same 1000-record list means 100,000
records will be stored in memory on the server!

Hope this helps.

MCA
Mike Amundsen
mca@E...
host your .NET Apps @ EraServer.NET
 

-----Original Message-----
From: Carole D. Sullivan [mailto:carolesullivan@e...] 
Sent: Friday, July 12, 2002 9:04 PM
To: ASP+
Subject: [aspx] Re: Editing Data in Datagrid

I am still new to .net, but unless you do something to persist your 
dataset, I don't think it is there anymore.  I had a onclick event and 
could not figure out why it could not see my data.  Showing the 
recordcount for my dataset proved to me that since I gone from one event

to another the data was no longer there.  Check you dataset recordcount:

Dim rowCount As Integer = DsOperScreens1.Tables(0).Rows.Count
Response.Write rowCount

Sorry I can't more, but this might get you moving again.

Surely someone out there can provide more info.....


Carole

> Hello Everyone and thanks for your help in advance.  I am working on
an 
a> pplication that display a list of employee names within a datagrid.  
Upon 
c> licking an Edit button, I want to be able to transfer the user to 
another 
s> creen (panel) within the same ASPX page for editing.  The form
contains 
e> mployee details and is quite lengthy, thus it does not work well with

i> nline editing.  Using the datakey attribute, I have been able to
figure 
o> ut how to send the EmployeeID to a delete function for deletion and
the 
a> dd function is straightforward.  But I am running into problems with 
p> erforming the edit.  Ideally, since a query has already been
performed, 
I 
w> ould like to work with the same disconnected dataset and populate the

the 
p> anel fields with the appropraite data - then allow the user to makes 
e> dits and save.  I cannot seem to figure out how to reference each of 
the 
f> ields for the particular data row.  I can pass the EmployeeID and 
simply 
r> equery the databse, but this seems like a waste of resources.  All of

the 
e> xamples that I have found use inline editing, which I simply think 
won't 
w> ork here.  Any ehlp would be greatly appreciated.  Thanks.

Message #4 by "Hugh McLaughlin" <hugh@k...> on Sat, 13 Jul 2002 12:53:17
All of the functions are located within the same ASPX page and thus state 
management is not an issue.  Like I mentioned in my post, I have no 
problems doing a delete in a similar fashion as I simply pass the ID 
through the Datakey.  I do the same thing for the update, but I also need 
to access the other in the DataGrid or DataReader.  I know this can be 
done, but I am not sure how.

> Remember that web pages are stateless - they do not retain any data in
memory between refreshes. 

Think about it like this: 
- browser calls the page at the server
- server loads the page into memory
- server executes any code in the page ( a click event)
- server creates new HTML to send to client and sends that
- server removes the page from memory

any data pulled during the execution of the page is not automatically
stored in memory on the server or the client.

However you *can* persist data using:

- cookies (sent back and forth in the header requests between client and
server)
- hidden HTML input fields (sent in the body of the page with each call
- session state (stored in server memory using a cookie to identify the
memory block to the client browser

one way to store a dataset between calls is to insert it into a session
var each time  before unloading the page. While this is possible, you
could eat up a lot of memory on the server for this - esp. if you have
lots of users reading the same data and storing their own copies on the
web server.  100 users accessing the same 1000-record list means 100,000
records will be stored in memory on the server!

Hope this helps.

MCA
Mike Amundsen
mca@E...
host your .NET Apps @ EraServer.NET
 

-----Original Message-----
From: Carole D. Sullivan [mailto:carolesullivan@e...] 
Sent: Friday, July 12, 2002 9:04 PM
To: ASP+
Subject: [aspx] Re: Editing Data in Datagrid

I am still new to .net, but unless you do something to persist your 
dataset, I don't think it is there anymore.  I had a onclick event and 
could not figure out why it could not see my data.  Showing the 
recordcount for my dataset proved to me that since I gone from one event

to another the data was no longer there.  Check you dataset recordcount:

Dim rowCount As Integer = DsOperScreens1.Tables(0).Rows.Count
Response.Write rowCount

Sorry I can't more, but this might get you moving again.

Surely someone out there can provide more info.....


Carole

> Hello Everyone and thanks for your help in advance.  I am working on
an 
a> pplication that display a list of employee names within a datagrid.  
Upon 
c> licking an Edit button, I want to be able to transfer the user to 
another 
s> creen (panel) within the same ASPX page for editing.  The form
contains 
e> mployee details and is quite lengthy, thus it does not work well with

i> nline editing.  Using the datakey attribute, I have been able to
figure 
o> ut how to send the EmployeeID to a delete function for deletion and
the 
a> dd function is straightforward.  But I am running into problems with 
p> erforming the edit.  Ideally, since a query has already been
performed, 
I 
w> ould like to work with the same disconnected dataset and populate the

the 
p> anel fields with the appropraite data - then allow the user to makes 
e> dits and save.  I cannot seem to figure out how to reference each of 
the 
f> ields for the particular data row.  I can pass the EmployeeID and 
simply 
r> equery the databse, but this seems like a waste of resources.  All of

the 
e> xamples that I have found use inline editing, which I simply think 
won't 
w> ork here.  Any ehlp would be greatly appreciated.  Thanks.


  Return to Index