Solved

C# STRING

Posted on 2006-10-19
3
197 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
[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
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
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 …

726 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