c# - Int to string - Saving back to a database from a textbox -
i saving values textbox database. how save number entered in textbox database. have tried following error saying input string not in correct format
newcarsrow.customerid = convert.toint32(textbox5.text); //i have tried newcarsrow.customerid = int.parse(textbox5.text);
i saving text entered textbox so
newcarsrow.surname = textbox1.text.tostring();
instead of using
newcarsrow.customerid = int.parse(textbox5.text);
you should try using
int customerid = 0; if(int.tryparse(textbox5.text.trim(), out customerid)) { newcarsrow.customerid = customerid; } else { // customer id received text box not valid int. relevant error processing }
now wont exception facing, , able perform relevant error handling.
Comments
Post a Comment