Solved

C# STRING

Posted on 2006-10-19
3
192 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:xDJR1875
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Image(2) 3 29
ConsoleSql 1 21
cs.Designer Issue(2) 2 23
Iterate a dictionnary to change values 4 31
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now