User577622187 posted
On the time entry page, if I enter nothing in the Hours text field, instead of getting a validation message ('Hours is a required value'), instead I abend with a message 'FormatException was unhandled by user code'. Below that it says 'Input string
was not in correct format'.
The code it blows up is the first line in the AddEntry_Click subroutine:
Dim timeEntry As TimeEntry =
New TimeEntry(Page.User.Identity.Name, Convert.ToInt32(CategoryList.SelectedValue), Convert.ToDecimal(Hours.Text), DateTime.Now, UserList.SelectedValue)
Below is the entire subroutine. What do I need to do to prevent this from happening should the user not key in a value into Hours?
==============================================================
Protected
Sub AddEntry_Click(ByVal sender
As Object,
ByVal e As System.EventArgs)
Handles AddEntry.Click
Dim timeEntry
As TimeEntry =
New TimeEntry(Page.User.Identity.Name, Convert.ToInt32(CategoryList.SelectedValue), Convert.ToDecimal(Hours.Text), DateTime.Now, UserList.SelectedValue)
timeEntry.Description = Description.Text
timeEntry.Save()
Description.Text =
String.Empty
Hours.Text =
String.Empty
ProjectListGridView.DataBind()
End Sub
===========================================================