473,607 Members | 2,674 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 2290
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
5649
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 and might be corrupted". I am wandering what kind of client side problem may cause this error? Is it possible that user uses a browser which has local cache turned on all the time? Thanks for any suggestion.
2
3614
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
2946
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 server side event happens, resulting in Page_load event. Page_Load is also happening when I navigate to the next page. That means Page_load will always happen when I navigate to the next page. Please correct me If I have totally misunderstood...
1
4122
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. The problem with this is that the refresh will either delete another record or generate an exception, something like this: An error has occurred because a control with id 'ctl00$Main$UserGrid$ctl11$ctl00' could not be located
0
2089
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 sets a connection string to the database. The content page has a simple gridview that should show records from the selected database. Initial content page displays data from correct place. first change of dropdownlist correctly updates content...
3
2425
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 interface. The interface would expect some sort of "end user identitifier" argument, perhaps a GUID. I thought that this user identifier GUID could be generated by a common user control (either from state information held on the client cookies, or in...
10
2926
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 users! i've looked around online and can find nothing to do this, or in the SDK docs. i thought .Net 2.0 would have something more out-of-the-box for this type of performance measuring but i can't find any. i was thinking about running a timer...
3
2579
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 problems in the following (rather common, I guess) scenario: The controls are created dynamically. Their number and contents
2
3184
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 to get a little more information to lock down what I think I know and also to answer a couple little questions. Given a base page, and the page inheriting it, as I understand it, the page lifecycle flows like this: 1) Page is requested
0
8049
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8463
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8128
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8322
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6803
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5471
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3953
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4013
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1574
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.