View State does not contain data after F5

P

Philip Poole

Hello everyone,

I have been using controls for the first time and with the controls I have
been using the view state. I have now get a web page aprt from when I press
F5 on the first screen thatis loaded up. After I have clicked on a object
f5 works.

What I have found so far is that after pressing f5 on that first screen the
viewstate is empty. As far as I understand it, there should be data in
there. The process is as follows: -

MainPage.PageLoad() { //stuff here }

MyControl.PageLoad() {
PopulateDataGrid()
}

//in MyControl the datagrid has a ItemDataBoundHandler

ItemDataBoundHandler(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e ) {
//check to see if a value is equal an inital condition
//this can vary acording to user selections
if (myValue == intialValue) {
//change appearence of that row in the datagrid
//ViewState["Value"]
}
}


Now all this works and I have debugged it and it sucessfully sets the
ViewState with that value. However when I press F5, the propgram will crash
saying the viewstate["value"] is empty.

Please tell me what I am doing wrong!

Many Thanks in advance

Philip
 
L

Lucas Tam

Now all this works and I have debugged it and it sucessfully sets the
ViewState with that value. However when I press F5, the propgram will
crash saying the viewstate["value"] is empty.

ViewState is only read on a postback.

F5 is not a postback but a reload, so whatever value you set on the
previous load is not read by the reload.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top