Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Can Anyone answer me...

Error coding:


int quantity = Convert.ToInt32(((TextBox)DataList1.Controls[0].FindControl("txtquantity")).Text);


Error:

Input string was not in a correct format.
Posted
Comments
JF2015 25-Nov-11 1:12am    
So, what is the content of txtquantity.Text?
[no name] 25-Nov-11 1:13am    
integer, maybe?
rajeevcapgeminiindia 25-Nov-11 1:15am    
If the txtquantity text is insteadof numeric, it will always disaply such error.
So make sure that your input is in correct format.

TryParse() might help you. Please have a look following link.

TryParse
Hope it helps.
 
Share this answer
 
Comments
RaisKazi 25-Nov-11 1:29am    
My 5 for "TryParse" suggestion.
Mohammad A Rahman 25-Nov-11 1:31am    
thank you very much.
Sergey Alexandrovich Kryukov 25-Nov-11 2:56am    
This is right API to use, but it won't help OP as the issue is the argument of TryParse or Parse. OP needs to check the value, use Debugger, get understanding of what's going on. If OP replace Convert with TryParse, the result will be the same, only without exception which was suggestive. :-<

(I did not vote.)
--SA
Mohammad A Rahman 25-Nov-11 5:06am    
Thank you.
First of all make sure that text box contains a value.. In case of null value it also shows that. Then make sure that it contains proper integer value.
I think it can help you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900