Yes, Arun's code sample is the correct solution! Session is not required here at all.
Maya, To answer your question... the web is stateless... It's all Moh- Maya !! :P On Apr 11, 7:04 am, ARUN KUMAR <[email protected]> wrote: > I alter your code : > > public partial class _default : System.Web.UI.Page > { > > Employee emp; > > protected void Page_Load(object sender, EventArgs e) > { > if (!Page.IsPostBack) > { > emp = new Employee ().GetEmployee(); > viewstate("Emp")=emp; // Load to viewstate > } > else > emp=viewstate("Emp"); // retrive from viewstate > } > > protected void btn_confirm_Click(object sender, EventArgs e) > { > > emp.FirstName = "something"; > emp.LastName = "something"; > > } > } > > 2009/4/10 Maya <[email protected]> > > > > > > > > > Hi guys, Is there a reason why emp object is becoming null when I > > click the submit button?? > > > It works fine when I first load the page, the object gets populated, > > but when btn_confirm_Click() gets executed the emp is null. > > > Thanks, > > > Maya. > > > public partial class _default : System.Web.UI.Page > > { > > > Employee emp; > > > protected void Page_Load(object sender, EventArgs e) > > { > > if (!Page.IsPostBack) > > { > > > emp = new Employee ().GetEmployee(); > > > } > > } > > > protected void btn_confirm_Click(object sender, EventArgs e) > > { > > > emp.FirstName = "something"; > > emp.LastName = "something"; > > > } > > } > > -- > Regards > ******************* > *C.Arun Kumar * > *******************- Hide quoted text - > > - Show quoted text -
