Solved

C# STRING

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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