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 *
*******************