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"].ToStr ing();
switch(DisplayCountry.ToSt ring())
{
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
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"].ToStr
switch(DisplayCountry.ToSt
{
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
ASKER
Hi hongjun
1000 is a valid case
Regards
Caz
1000 is a valid case
Regards
Caz
have you tried displaying the value?
ASKER
yes it displays 1000
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks ihenry
That solved the problem
Caz
That solved the problem
Caz
Maybe you need a default in case none of the case condition fit.
case "1000":
//
...
default:
// here