In page load I'm saving a query string int value in a viewstate. Then I save it to my DB. Here is the code I use to retrieve viewstate value and validating it:
protected int CurrentCom
{
get
{
if (ViewState["CurrentCom"] == null)
return 0;
else
{
int temp;
if (int.TryParse(ViewState["CurrentCom"].ToString(), out temp))
return temp;
else return 0;
}
}
set { ViewState["CurrentCom"] = value; }
}
Is there a better way to make this shorter?