473,507 Members | 13,917 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

page life cycle events and dynamic content in gridview

9 New Member
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 2282
kenobewan
4,871 Recognized Expert Specialist
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
5635
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
3605
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
2938
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
4110
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
2081
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
2421
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
2913
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
2575
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
3181
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...
0
7221
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7029
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7481
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5039
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1537
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.