I am using formview to update a table with employee details. However if they omit their phone number I want to add the value of their default company number from another table. I then want to use the itemUpdating event to test whether the user’s phone number is left blank and if it is then assign the default number which I’ve got from another datasource and assigned to a literal on formview. The problem I have is that although the textbox appears to have been assigned the default number the value of that field for the employee table is blank, when the update is complete the phone number is missing. This is the code that I’m using:
Private Sub FormView1_ItemUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewUpdateEventArgs) Handles FormView1.ItemUpdating
Dim tel As TextBox = DirectCast(FormView1.FindControl("uPhoneTextBox"), TextBox)
If tel.Text = "" Then
Dim cphone As Literal = DirectCast(FormView1.FindControl("cPhoneNo"), Literal)
tel.Text = cphone.Text
DataBind()
End If
End Sub
I’ve looked for examples of this on the web and not found anything similar. Any help would be much appreciated.
Private Sub FormView1_ItemUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewUpdateEventArgs) Handles FormView1.ItemUpdating
Dim tel As TextBox = DirectCast(FormView1.FindControl("uPhoneTextBox"), TextBox)
If tel.Text = "" Then
Dim cphone As Literal = DirectCast(FormView1.FindControl("cPhoneNo"), Literal)
tel.Text = cphone.Text
DataBind()
End If
End Sub
I’ve looked for examples of this on the web and not found anything similar. Any help would be much appreciated.