Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

dropdownlist - cast value as integer

Posted on 2008-10-06
4
Medium Priority
?
790 Views
Last Modified: 2012-05-05
I have a dropdownlist below--

In the event handler...i want to assign the value to this:

 Locales.CurrentLocaleId = ddlLocale.SelectedItem.Value;

But  Locales.CurrentLocaleId is integer. I tried (int) ddlLocale.SelectedItem.Value;
but that didnt work either...how can I do this?
<asp:DropDownList ID="ddlLocale" runat="server" 
                    onselectedindexchanged="ddlLocale_SelectedIndexChanged">
                    <asp:ListItem Value="1033" Text="Ebglish" Selected="True"></asp:ListItem>
                    <asp:ListItem Value="1031" Text="German" ></asp:ListItem>
                </asp:DropDownList>

Open in new window

0
Comment
Question by:Camillia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 22650632
Try int.Parse(ddlLocale.SelectedValue.ToString)
0
 
LVL 7

Author Comment

by:Camillia
ID: 22650765
that worked ( had to do ToString() )...

but howcome (int) dlllocale.selectedvalue.tostring(); didnt work?

why do I need to add "Parse"..is it because C# wont allow conversion between int and string/
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 22650985
You can't cast from a string to an int that way.  If you are looking for a reason, I don't think that I can give you one.  I just rely on the fact that the compiler complains about it.
0
 
LVL 7

Author Comment

by:Camillia
ID: 22651162
thanks.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

688 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