Problem with case not returning correct results

Hi
can anyone help with this problem
When using the case statement the code is returning the value not the text.
Code below.

<script runat="server">
void Page_Load(Object Src, EventArgs E)
{
DisplayCountry.Text = Session["CRCountry"].ToString();
switch(DisplayCountry.ToString())
{
case "1000":
DisplayCountry.Text ="Afghanistan";
break;
more case blocks
}
}
</script>
<asp:Label ID="DisplayCountry" runat="server"/>

Instead of returning the country name, it returns the value from the session.
Any help would be appreciated
Caz


BeginningWebDesignAsked:
Who is Participating?
 
ihenryConnect With a Mentor Commented:
I think it should be like this

switch(DisplayCountry.Text.ToString())
{
  ...
  ...
0
 
hongjunCommented:
Perhaps none of the case condition is satisfied.
Maybe you need a default in case none of the case condition fit.

case "1000":
    //
...
default:
    // here
0
 
BeginningWebDesignAuthor Commented:
Hi hongjun

1000 is a valid case

Regards
Caz
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
hongjunCommented:
have you tried displaying the value?
0
 
BeginningWebDesignAuthor Commented:
yes it displays 1000
0
 
BeginningWebDesignAuthor Commented:
Thanks ihenry

That solved the problem

Caz
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.