C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Input string was not in a correct format


Posted Date: 05 Jul 2008      Total Responses: 6

Posted By: adil       Member Level: Bronze     Points: 1



public void populate_type()
{
try
{
if (ddl_pac_id.SelectedValue.ToString() == "0")
{
txt_type.Text = "";
}
else
{
id = int.Parse (ddl_pac_id.SelectedItem.ToString());
str1 = "select type from prmy_acnts where pac_id=" + id;
cmd = new OleDbCommand(str, con.fn_connection());
dr = cmd.ExecuteReader();
if (dr.Read())
{
txt_type.Text = dr["type"].ToString();
}
else
{
con.fn_disconnect();
}
}
}

here is the code i wrote...i'm getting the following exception...


System.FormatException: Input string was not in a correct format. at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at System.Int32.Parse(String s) at Account_group.populate_type() in e:\AceErp\Accounts\Account_group.aspx.cs:line 59






Responses

Author: rahul    05 Jul 2008Member Level: GoldRating:     Points: 0

on which line u r getting this error..


Author: adil    05 Jul 2008Member Level: BronzeRating:     Points: 1

id = int.Parse (ddl_pac_id.SelectedItem.ToString());

here i'm getting the error...




Author: Namedm    05 Jul 2008Member Level: SilverRating:     Points: 1

Trim the dropdowns selected value
before passing it to int.Parse



Author: Namedm    05 Jul 2008Member Level: SilverRating:     Points: 0

ddl_pac_id.SelectedItem.Trim();



Author: Ebenezer    08 Jul 2008Member Level: SilverRating:     Points: 1

hi

on which line you are getting error..

regards



Author: adil    09 Jul 2008Member Level: BronzeRating:     Points: 1

id = int.Parse (ddl_pac_id.SelectedItem.ToString());

here i'm getting the error...



Post Reply
You must Sign In to post a response.
Next : Failure sending mail
Previous : tab control help meee....
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use