asp.netformview

Access FormView in the ItemUpdated event


When I want to modify a FormView element like below, it works fine in the DataBound event, but it doesn't work with the ItemUpdated event (and also not with the ItemUpdating event). Why is that?

This works

Protected Sub FormView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.DataBound        
    cType(sender.FindControl("myField"),TextBox).text="Some value"  
End Sub

This does not work

Protected Sub FormView1_ItemUpdated(ByVal Sender As Object, ByVal e As FormViewUpdatedEventArgs) Handles FormView1.ItemUpdated
    cType(sender.FindControl("myField"),TextBox).text="Some value"  
End Sub

Solution

  • It appears that there is a FormView.DataBound event after the FormView.ItemUpdated event, which causes this.