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
Solved

C# STRING

Posted on 2006-10-19
3
195 Views
Last Modified: 2010-04-16
Experts,

I need urgent help with a string. ie I have a drop down list which has one of the value $100,00.
in my code i get this value using ddlList1.SelectedItem.Text,  I need to do some validation in code something like this
if(ddlList1.SelectedItem.Text>$100,00)
{

}
how do i convert this to do validation, If i write above like that, It has a $ sign and a charcter. which is not accepatble.
Any urgent help is appreciated
0
Comment
Question by:archinpalli
3 Comments
 
LVL 17

Expert Comment

by:Daniel Reynolds
ID: 17771026
You will need to use System.Convert.... () to get the value of the string to a number variable. Wrap it in a try/catch in case the value is not a number.

then compare the value to your rule.
0
 

Author Comment

by:archinpalli
ID: 17771041
Can you post a sample code if you have in mind
0
 
LVL 6

Accepted Solution

by:
MuhammadAdil earned 125 total points
ID: 17771101
Hello Dear,
                 Use this code
            string selectedItem = ddlList1.SelectedItem.Text;
            int index = selectedItem.IndexOf("$");
            selectedItem = selectedItem.Remove(0, 1);
            selectedItem = selectedItem.Replace(",","");
            if(int.Parse(selectedItem)>10000)
{
               
}
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

861 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