Groups | Blog | Home
all groups > asp.net datagrid control > february 2006 >

asp.net datagrid control : editing / updating dynamic dgrid



Elton Wang
2/23/2006 12:20:50 PM
Hi Dirk,

You can have a page level collection variable, e.g.Hashtable, or Arraylist.
When postback get data from datagrid and put in the collection variable,
then rebind datagrid. In UpdateCommand you can use data from collection
variable.

HTH


[quoted text, click to view]

Darren Kopp
2/23/2006 2:48:58 PM
try something like this, it should alleviate postback problems

Private Sub BindGrid()
' binding code
End Sub

and then inside the Page_Load function put...

If Not Page.IsPostBack Then
BindGrid()
End If

and finally, inside your update method, after you have updated the
data, call BindGrid().

Then you won't have problems with postback and losing data.
dirk van waes
2/23/2006 4:52:48 PM
Hello,
I have a dynamic datagrid , made and filled by VB code.
No problem here! But when I try to update my db via this datagrid, Im in
deep trouble!
The problem is that when I do a databind on every postback, I loose the
updated values. When I don't do a databind of the grid on page_load (on
postback), the event dgName_UpdateCommand is clearly not triggered at all!
How can I work around this problem? The datagrid needs to be made dynamicly,
since the data changes every time I use the datagrid (=students, depending
on the choosen class, partition and period)
TIA

Dirk



Elton Wang
2/23/2006 6:14:36 PM
As Dirk menntioned, it's dynamically created datagrid. Without binding
datagrid, it cannot fire update event.


[quoted text, click to view]

Darren Kopp
2/24/2006 8:39:42 AM
His way is most likely the easiest. You could catch the bubbled event
at the page level, but its probably easier to use an array to store
data.

Good luck,
Darren Kopp
http://blog.secudocs.com/
dirk van waes
2/24/2006 2:00:54 PM
Hi Elton and Darren,
I'll think the solution of Elton is the right one that can help me. I give
it a try.
Darren: The problem was -as Elton daid- that the update-event isn't fired
without the data!

Thanks for your time. Greetings from Belgium
Dirk




"Elton Wang" <elton_wang@hotmail.com> schreef in bericht
news:%237KAE8MOGHA.3788@TK2MSFTNGP09.phx.gbl...
[quoted text, click to view]

ForList
2/24/2006 3:03:22 PM
[quoted text, click to view]
AddThis Social Bookmark Button