Solved

How can I check parameter or session collection for a key?

Posted on 2003-10-27
2
198 Views
Last Modified: 2010-04-16
How can I check if a parameter exists in the parameter collection or a key exists in
the Session collection?  

Currently I get an error when I do this and when there is no parameter
passed to the page: Request.Params["DBType"].

Samething I get when I do this with the Session object.

The error I get is this:
System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 97:             private void Page_Load(object sender, System.EventArgs e)
Line 98:             {
Line 99:                   if(Request.QueryString["DSNType"].ToString() != "")
Line 100:                  {
Line 101:                              Response.Write("yes");
 
Thanks,

Andrzej
0
Comment
Question by:andw928
  • 2
2 Comments
 
LVL 10

Accepted Solution

by:
smegghead earned 50 total points
Comment Utility
put something like..

object MyObj=Request.QueryString["DSNType"];
if (MyObj!=null)
{
    Response.Write("yes");
}
0
 
LVL 10

Expert Comment

by:smegghead
Comment Utility
blimey, what do I have to do for an 'a' ?? do you want a tip ?

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now