Hello,
I have a simple data entry webform that is used to add records toa database. Some of the controls are linked to fields in the database that always require a value, others do not.
I also have a submit button that when clicked add the record to the database with the entered and selected values.
The controls that require a value are application(via text box), vendor(via dropdownlist) and software tye (via dropdownlist). Now, At the moment when i leave one of these fields empty and click the the submit button i get an error like: 'Field 'GKLS Software.Application' cannot be a zero-length string.'
This i expect so to counter this i put in the following if statements in my submit click event to handle this:
However this does not work and i get the same error. So what do i need to do to take care of this problem? Please Help!
I have a simple data entry webform that is used to add records toa database. Some of the controls are linked to fields in the database that always require a value, others do not.
I also have a submit button that when clicked add the record to the database with the entered and selected values.
The controls that require a value are application(via text box), vendor(via dropdownlist) and software tye (via dropdownlist). Now, At the moment when i leave one of these fields empty and click the the submit button i get an error like: 'Field 'GKLS Software.Application' cannot be a zero-length string.'
This i expect so to counter this i put in the following if statements in my submit click event to handle this:
VB.NET:
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] txtApplication.Text = "" [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]lblapp.Text = "You must Enter an Application"
[/SIZE][SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] ddlVendors.SelectedItem.Value = "" [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]lblvend.Text = "You must select a Vendor"
[/SIZE][SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] ddlsoftwaretype.SelectedItem.Value = "" [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]lblsofttype.Text = " You must select a Software Type"
[/SIZE][SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
However this does not work and i get the same error. So what do i need to do to take care of this problem? Please Help!