In page_load event
int a;
if (ViewState["no"]==null)
{
ViewState["no"] = 0;
}
a = Convert.ToInt32( ViewState["sum"]);
i = Convert.ToInt32(ViewState["no"]) + 1;
ViewState["no"] = i;
if (a == 0)
{
a = Convert.ToInt32(ViewState["no"]);
}
if (ViewState["sum"] == null)
{
a = 0;
}
ViewState["sum"] = a + Convert.ToInt32(ViewState["no"]);
Response.Write(ViewState["no"]+"sum:"+ViewState["sum"]);
Value get added with previous value store in ViewState in every postback
int a;
if (ViewState["no"]==null)
{
ViewState["no"] = 0;
}
a = Convert.ToInt32( ViewState["sum"]);
i = Convert.ToInt32(ViewState["no"]) + 1;
ViewState["no"] = i;
if (a == 0)
{
a = Convert.ToInt32(ViewState["no"]);
}
if (ViewState["sum"] == null)
{
a = 0;
}
ViewState["sum"] = a + Convert.ToInt32(ViewState["no"]);
Response.Write(ViewState["no"]+"sum:"+ViewState["sum"]);
Value get added with previous value store in ViewState in every postback
No comments:
Post a Comment