FormView Label problem...
I'm having no success with a bound label in a FormView. I want the label to display the date and time when a record is edited. I've tried the Item_Updated event but nothing happens to the label. Any thoughts?
Protected Sub FormView1_ItemUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewUpdatedEventArgs ) Handles FormView1.ItemUpdated
Dim datetime As Date
Dim DateLabel As Label
DateLabel = CType(FormView1.Row.FindControl("DateLabel"), Label)
datetime = Now()
If DateLabel Is Nothing Then
DateLabel = New Label
DateLabel.Text = datetime.ToLongTimeString()
Else
DateLabel.Text = datetime.ToLongTimeString()
End If
End Sub
Even if I just set the DateLabel.Text= "Hello" in the event handler, the label doesn't change in the FormView. If the bound control is Null and I exclude the If Then statement in the code, there's not even a null exception error that's thrown, causing me to think that the event is not even firing. However, if I use the FormView1_DataBinding event, the label does get updated but with every databinding event of the FormView, even if an update has occurred or not. I have no clue.
|