Hi,
I had a problem to get value from editform template from a validator event.
| Public Sub ValidateOccupation(ByVal source As Object, ByVal e As ServerValidateEventArgs) |
| ' verifie s'il est en edition |
| Dim mess As StringString = String.Empty |
| If grdTerritory.EditItems.Count > 0 Then |
| Dim Description As StringString = String.Empty |
| Dim lstOcc As List(Of Occupation) = New List(Of Occupation) |
| Dim editedItem As GridItem = grdTerritory.EditItems(0) |
| DirectCast(editedItem.FindControl("lblErrorMessage"), Label).Text = mess |
| If GetInfoEditableItem(editedItem, Description, ID.ToString, lstOcc) Then |
| Try |
| mess = OccupationValidator(ID.ToString, lstOcc, TerritoryAction.Update) |
| Catch ex As Exception |
| Throw |
| End Try |
| End If |
| If Not String.IsNullOrEmpty(mess) Then |
| e.IsValid = False |
| Else |
| e.IsValid = True |
| End If |
| End If |
This DirectCast(editedItem.FindControl("lblErrorMessage"), Label) crash on NullReferenceException
How can access my label from my validator event into editTemplate on my item in editmode?
ty