Click here to Skip to main content
15,920,576 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hai,

i am passing the query string value in the same page..the following is the code i used but i am getting object instance reference set to null

<pre>

if (Request.QueryString[&quot;product_type&quot;].ToString()== null)
{
if (Request.QueryString[&quot;product_type&quot;].ToString() == String.Empty)
{
this.product_type = &quot;Acer&quot;;
}
}
else
{
this.product_type = Request.QueryString[&quot;product_type&quot;].ToString();
}
DisplayContents();</pre>
Posted
Updated 21-Jul-11 5:09am
v2
Comments
Uday P.Singh 21-Jul-11 11:14am    
why are you doing so? when you can use view state

if (Request.QueryString["product_type"] != null)
{
   this.product_type = Request.QueryString["product_type"];
}
else
{
   this.product_type = "Acer";
}
 
Share this answer
 
Create a protected property (protected, just in case you need to reference it from the page), and use that to get your product type.

protected string _productType
{
get
{
if (!String.IsNullOrEmpty(Request.QueryString["product_type"])
    return Request.QueryString["product_type"]
else
    return "Acer";
}
}


Now just reference that where ever you need it. Remember, Request.QueryString returns a string, so you dont need to cast it to a string!
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900