On May 28, 2:04*pm, iHavAQuestion
<iHavAQuest...@discussions.microsoft.comwrote:
I have a registration from in a aspx page.
I also have a textbox contol which takes the int value to be inserted in the
database.
this control is not mandatory.
When I click on the save button, the error is raised saying that the inout
string is not in a correct format.
LtcCaseReviewData.DcisIICaseNumINT= Convert.ToInt32(txtCaseNumber.Text);
Can any one give me the solution
Convert.ToInt32() does not accept empty string.
So if the textbox is not required and is empty that code will attempt
Convert.ToInt32("") will fail with that error.
Here is the fix: (VB sry)
If txtCaseNumber.Text <String.Empty then
LtcCaseReviewData.DcisIICaseNumINT=
Convert.ToInt32(txtCaseNumber.Text)
Else
LtcCaseReviewData.DcisIICaseNumINT= -1 ' (or whatever your
default value is)
End If