473,386 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Please help me understand this PostBack Issue

I am inserting a row in a database. All that works fine. What I now
need is the last inserted id from the database. I can get that. Again
all working.

Then what I need to have is that same last inserted id key to be
available when the page reloads. When I press the button to insert the
data, I can do this:

Session("last")=LAST_ID;
Response.Write("My row id is: " + Session("last"));
//this works and is inside my INSERT button_click event

But when the Page_Load comes back I cannot see it. I try this:

if (Page.IsPostBack)
Response.Write("My row upon postback is: " + Session("last"));
//this fails upon postback in the Page_Load

It is just blank. Nothing there.

Instead of a Session variable, I have tried a static variable, (I think
ViewState, but am not sure), a global variable, nothing holds the data
upon PostBack.

Thank you for any help.

Nov 19 '05 #1
4 1329
And what I don't get is that when I do a trace it shows my INSERT code
in the Begin PostBack which looks like I would have access to the
variable.

Nov 19 '05 #2
I'm sorry to keep responding to myself, but it looks like the lifecycle
is as follows:

Page_Load
Button_click

So,

Page_Load fails to show a Session Variable or any other because it has
not been initialized yet.
Button_click is where the row is inserted and the last ID is given.

But because the Button_click has fired after the Page_load the
page_load never sees the value.

So I must find a way to get the last row id..oh wait..I populate the
controls after the insert in that click event instead of the Page_Load
event.

Thanks!

Nov 19 '05 #3
Umm, glad to be of assistance??? :)

Mythran

Nov 19 '05 #4
ne***********@gmail.com wrote:
I'm sorry to keep responding to myself, but it looks like the
lifecycle is as follows:

Page_Load
Button_click


RTM...

http://msdn.microsoft.com/library/de.../en-us/cpguide
/html/cpconControlExecutionLifecycle.asp

;-)

--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rhys | last post by:
I have a page which has an IFrame on it. The src of the IFrame is a page with a datagrid on it. The Datagrid has bound template columns. The columns of the datagrid pass the bound data value of...
4
by: John | last post by:
Hi all, I have posted this type of question quite a few times but to date, no-one has actually been able to provide me with a solution. I really need to understand how to do this properly. My...
7
by: Anand | last post by:
Hi All, The postback on my desktop stopped working. I am trying to run the webapplication locally on my desktop and the Postback on my home page won't trigger on any of my dropdown selections. The...
5
by: Tom Anderson | last post by:
I am currently having an issue with an ASP.Net 1.1 Web page that does the following remotely but not locally. Click on a control Check for postback, if postback, handle the event, otherwise...
8
by: John Austin | last post by:
I need to understand why if I add a control and use AddHandler to connect its click event, it will work in Page_Load, but not in a Button_Click. The idea is that the user types some data, presses...
11
by: antonyliu2002 | last post by:
I know that this has been asked and answered thousands of times. As a matter of fact, I know that I need to say If Not Page.IsPostBack Then 'Do something End If for things that needs to be...
6
by: Dmitry Duginov | last post by:
Hi, I have the following label markup (label is inside FormView): <asp:Label ID="lblIndicatorReady" runat="server" Text="RE" ToolTip="Ready" BackColor='<%#...
2
by: =?Utf-8?B?SlA=?= | last post by:
Hi all. I'm having a problem with a postback issue and I think it's cache related. Here's my setup: I have a web site that has a signup section. This has simple things like name, age, birth...
4
by: Doogie | last post by:
Basically, I have two custom dates the user can enter via a popup calendar. These dates are stored into text boxes. Then the user can click a button (Run Report) and those values (as well as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.