472,807 Members | 5,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,807 software developers and data experts.

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 2231
kenobewan
4,871 Expert 4TB
I believe that you are stuck with this situation unless you use a disconnected database.
Dec 16 '07 #2

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

Similar topics

5
by: Hardy Wang | last post by:
Hi all: I developed a web site, it passed various testing internally. When I put this site in production, I receive some error reports from this site saying "the viewstate is invalid for this page...
2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
6
by: MooreSmnith | last post by:
When I navigate to the next page using Response.Rediect("MyNextPage.aspx") current page Page_Load event is called. What I may wrongly understood is that post back will happen whenever there is any...
1
by: J055 | last post by:
Hi I have a GridView which includes the ability to delete rows. This works fine accept for when a naughty user decides to refresh the browser thereby posting the same delete command instruction....
0
by: Managed Code | last post by:
Hello All, Here is my issue and thanks in advance for any assistance. I have a base page with a dropdownlist that fires an event with the selected index. The content page catches the event and...
3
by: Griff | last post by:
I want to build a set of compiled user controls to incorporate into a web site. The majority of user controls will be placed on specific web page and these controls would share a common...
10
by: Tim_Mac | last post by:
hi, i would like to display a discreet message on all my pages indicating how long the server took to render the page. full tracing is not an option because it would freak out my non-technical...
3
by: HP | last post by:
Hi there The problem of dynamically created controls vs viewstate is widely known one. To access values of controls they have to be recreated on Page_Load. Unfortunately it causes many...
2
by: Gary W. Smith | last post by:
I have a page that inherits from a base page that is currently overriding all of the On* events. For the most part I'm accomplishing everything I set out to do with the inheritance, but I wanted...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.