In the below code, You got that error because your Session["User_ID "] was null and when you
try to return a string representation of that you got the object reference not set to an instance of an object error.
There is difference between .Tostring() and casting Convert.ToString().
if (!Page.IsPostBack)
{
ViewState["purid"] = Request.QueryString["User_ID"].ToString();
}
Solution for Object Reference not set to an Instance of an
Object in ASP.NET
ToString throw null reference
error but Convert.ToString() does not throw null reference error.
if (!Page.IsPostBack)
{
ViewState["purid"] = Convert.ToString(Request.QueryString["order_no_id"]);
}
No comments :
Post a Comment
Ask a Question?