Checking for the existence of a variable in queryString

  • Thread starter Thread starter Andy B.
  • Start date Start date
A

Andy B.

I want to provide 2 views for a page. The first view shows the
entire list of items on it. The other view shows only 1 item from the list
based on the ID in the query string that comes from an rss feed. How would I
check for the existence of ID in the query string?
 
        I want to provide 2 views for a page. The first view shows the
entire list of items on it. The other view shows only 1 item from the list
based on the ID in the query string that comes from an rss feed. How would I
check for the existence of ID in the query string?

Andy, you to get query string use QueryString Property
http://msdn.microsoft.com/en-us/library/system.web.httprequest.querystring.aspx

Example:

if (Request.QueryString["ID"] != null)
{
string id = Request.QueryString["ID"];
..... to get 1 item only
} else {
.... to get all items
}

Hope this helps
 
Back
Top