Formview itemupdating not updating textbox value

Nic

Joined
Sep 11, 2009
Messages
1
Reaction score
0
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top