Link to home
Start Free TrialLog in
Avatar of BeginningWebDesign
BeginningWebDesign

asked on

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


Avatar of hongjun
hongjun
Flag of Singapore image

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
Avatar of BeginningWebDesign
BeginningWebDesign

ASKER

Hi hongjun

1000 is a valid case

Regards
Caz
have you tried displaying the value?
yes it displays 1000
ASKER CERTIFIED SOLUTION
Avatar of ihenry
ihenry

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks ihenry

That solved the problem

Caz