Home > Archive > ASP .NET Datagrid Control > February 2006 > editing / updating dynamic dgrid
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 |
editing / updating dynamic dgrid
|
|
| dirk van waes 2006-02-23, 7:03 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 2006-02-23, 7:03 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
"dirk van waes" <dirk.van.waes@telenet.be> wrote in message
news:ALlLf.275086$_n3.8866953@phobos.telenet-ops.be...
> 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
>
>
>
>
| |
| Darren Kopp 2006-02-23, 7:03 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.
| |
| Elton Wang 2006-02-23, 7:03 pm |
| As Dirk menntioned, it's dynamically created datagrid. Without binding
datagrid, it cannot fire update event.
"Darren Kopp" <darrenkopp@gmail.com> wrote in message
news:1140734938.815707.273370@v46g2000cwv.googlegroups.com...
> 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 2006-02-24, 7:01 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...
> As Dirk menntioned, it's dynamically created datagrid. Without binding
> datagrid, it cannot fire update event.
>
>
> "Darren Kopp" <darrenkopp@gmail.com> wrote in message
> news:1140734938.815707.273370@v46g2000cwv.googlegroups.com...
>
>
| |
| Darren Kopp 2006-02-24, 7:01 pm |
| 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/
| |
| ForList 2006-02-24, 7:01 pm |
| Darren Kopp wrote:
> 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/
>
Were we able to solve this problem? I am also facing the same problem. :)
|
|
|
|
|