469,648 Members | 1,143 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,648 developers. It's quick & easy.

page life cycle events and dynamic content in gridview

Hello,

I have a gridview that is filled with a datasource & template fields dynamically.
( that has to be done because i ask the user for a datasource)

anyway, i started out creating a static but empty grid. and added the template controls and datasource & activated grid.DataBind() in the page_load event.

that gave me all the info when the page loaded on screen.

now i have an edit and update buttons on each row and pressing the edit button starts the page cycle and recreated the grid including databind and then goes on to the grid_onedit event.

here i changed the grids editindex, and here i also save the grid row to session so i would have to old_row saved.

when the page loads i change some data and press the update button.

as it should, page_load starts and the grid is created and grid.DataBind() is activated and now the the grid_onupdate starts and i update the datasource and then do another grid.DataBind() (i do this so that changes are done to the grid)

well, it seems alright but it's not.

i don't like to do 2 databind events on the grid each postback and moreover, i dont think the way to save the old_row data should be via the session.
i'm sure microsoft or someone thought of a better idea.

the problem is that if i remove the first DataBind the old_row data is still not created when the onedit event is started and i have no data to take.

and worse still is that the update event isn't firing when i do this becuase the row that i pressed the update button have not been created yet.

so, i am asking some one who is expirienced with asp.net and dynamic gridview. what's the way to go here?

when is the appropriate event to do databind and how do i get the old and new record in the update event as i should.

thanks,
koren.
Dec 15 '07 #1
1 2054
kenobewan
4,871 Expert 4TB
I believe that you are stuck with this situation unless you use a disconnected database.
Dec 16 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by John Lau | last post: by
6 posts views Thread by MooreSmnith | last post: by
3 posts views Thread by Griff | last post: by
10 posts views Thread by Tim_Mac | last post: by
2 posts views Thread by Gary W. Smith | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.