View State does not contain data after F5

  • Thread starter Thread starter Philip Poole
  • Start date Start date
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
 
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.
 
Back
Top