Click here to Skip to main content
15,884,537 members
Home / Discussions / C#
   

C#

 
Questionwhat is the problem ?? Pin
mmmickyyy21-Mar-13 23:16
mmmickyyy21-Mar-13 23:16 
AnswerRe: what is the problem ?? Pin
Nicholas Marty21-Mar-13 23:49
professionalNicholas Marty21-Mar-13 23:49 
SuggestionRe: what is the problem ?? Pin
Matt T Heffron22-Mar-13 7:29
professionalMatt T Heffron22-Mar-13 7:29 
QuestionObject reference not set to an instance of an object. Pin
mmmickyyy21-Mar-13 23:01
mmmickyyy21-Mar-13 23:01 
AnswerRe: Object reference not set to an instance of an object. Pin
Simon_Whale21-Mar-13 23:09
Simon_Whale21-Mar-13 23:09 
GeneralRe: Object reference not set to an instance of an object. Pin
mmmickyyy21-Mar-13 23:16
mmmickyyy21-Mar-13 23:16 
GeneralRe: Object reference not set to an instance of an object. Pin
~~Atul~~21-Mar-13 23:23
~~Atul~~21-Mar-13 23:23 
GeneralRe: Object reference not set to an instance of an object. Pin
Pete O'Hanlon21-Mar-13 23:23
mvePete O'Hanlon21-Mar-13 23:23 
Delete your other post there is no need for it. Click the Delete button at the bottom.

The reason you are getting a null reference is because you are trying to ToString where one of your references is not present. This is the thing that's causing the problem. What you need to do is actually test the result from the QueryString before you attempt to do anything with it. You could use something like this:
C#
lblStudentName.Text = GetResultFromQueryString("studentName");

private string GetResultFromQueryString(string queryString)
{
  string returnValue = "No record found";
  object result = Request.QueryString(queryString);
  if (result != null && !string.IsNullOrWhiteSpace(result.ToString())
  {
    returnValue = result.ToString();
  }
  return returnValue;
}

I was brought up to respect my elders. I don't respect many people nowadays.

CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

AnswerRe: Object reference not set to an instance of an object. Pin
dusty_dex22-Mar-13 0:17
dusty_dex22-Mar-13 0:17 
GeneralRe: Object reference not set to an instance of an object. Pin
Pete O'Hanlon22-Mar-13 0:40
mvePete O'Hanlon22-Mar-13 0:40 
GeneralRe: Object reference not set to an instance of an object. Pin
dusty_dex22-Mar-13 1:34
dusty_dex22-Mar-13 1:34 
Questionabout the time period Pin
lightofheaven21-Mar-13 17:44
lightofheaven21-Mar-13 17:44 
AnswerRe: about the time period Pin
Boipelo21-Mar-13 21:07
Boipelo21-Mar-13 21:07 
QuestionHow to Draw Circles on GUI? Pin
Stuck At Zero21-Mar-13 10:32
Stuck At Zero21-Mar-13 10:32 
JokeRe: How to Draw Circles on GUI? Pin
Matt T Heffron21-Mar-13 10:54
professionalMatt T Heffron21-Mar-13 10:54 
AnswerRe: How to Draw Circles on GUI? Pin
Richard MacCutchan21-Mar-13 23:41
mveRichard MacCutchan21-Mar-13 23:41 
GeneralRe: How to Draw Circles on GUI? Pin
Stuck At Zero22-Mar-13 5:33
Stuck At Zero22-Mar-13 5:33 
GeneralRe: How to Draw Circles on GUI? Pin
Richard MacCutchan22-Mar-13 8:00
mveRichard MacCutchan22-Mar-13 8:00 
GeneralRe: How to Draw Circles on GUI? Pin
Stuck At Zero22-Mar-13 10:05
Stuck At Zero22-Mar-13 10:05 
GeneralRe: How to Draw Circles on GUI? Pin
Gerry Schmitz22-Mar-13 14:39
mveGerry Schmitz22-Mar-13 14:39 
GeneralRe: How to Draw Circles on GUI? Pin
Stuck At Zero22-Mar-13 14:56
Stuck At Zero22-Mar-13 14:56 
GeneralRe: How to Draw Circles on GUI? Pin
Gerry Schmitz22-Mar-13 17:43
mveGerry Schmitz22-Mar-13 17:43 
GeneralRe: How to Draw Circles on GUI? Pin
Stuck At Zero25-Mar-13 10:28
Stuck At Zero25-Mar-13 10:28 
GeneralRe: How to Draw Circles on GUI? Pin
Richard MacCutchan22-Mar-13 23:19
mveRichard MacCutchan22-Mar-13 23:19 
GeneralRe: How to Draw Circles on GUI? Pin
Gerry Schmitz23-Mar-13 8:57
mveGerry Schmitz23-Mar-13 8:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.