I have created an .aspx web page as a front-end form to my db table with the below code for an input field:
<asp:TextBox ID="tbxHowMany" runat="server"></asp:TextBox>
<asp:CompareValidator ID="cv" runat="server" ControlToValidate="tbxHowMany" Type="Integer"
Operator="DataTypeCheck" ErrorMessage="Value must be an integer" />
The database field is of type integer and is set to null.
The code behind looks like:
ql.Learners = Convert.ToInt32(tbxHowMany.Text);
The above field is not a required field, hence the null reference. However, upon testing the form the error "input string was not in a correct format" flags on submit. How can I alter my code to allow the form to accept a null value on submit?