[Ordering] trigger verification in DataGrid
Causeesvalidation in data
When we edit the DataGrid, we may have to verify the data entered by the user to ensure the correctness and integrity of the data. To solve this problem, there are many different ways, such as we can use the verification controls in vs.net, such as: RequiredFieldValidator. In this way, we need the UPDATE button in DataGrid to trigger whether the data entered by the user is empty. The UPDATE button contains a CausesValidation property.
Public property causesvalidation () as boolean
Members belong to: system.Web.ui.WebControls.LinkButton
Summary:
Get or set up a value indicating whether verification is performed when you click System.Web.ui.WebControls.LinkButton control.
We can use this property comes from control whether a WebControl triggered verification.
DataGrid ItemDatabase Event:
IF (E.Item.itemType = ListItemType.editItem) THEN
SetUpdateCommandcausesValidation (E.Item, true)
END IF
Private function setupdateCommandcausesvalidation (Byval Valor as boolean) AS String
IF (item.hascontrols ()) THEN
For Each Celula As Control in Item.Controls
For Each PossibleButton as Control in Celula.Controls
IF (PossibleButton.gettype (). Name.Equals ("DataGridLinkButton"))
DIM LBT AS LINKBUTTON = CTYPE (POSSIBLEBUTTON, LINKBUTTON)
IF (lbt.text.equals (getupdateColumnText ())))
Lbt.causesvalidation = VALOR
EXIT for
END IF
END IF
NEXT
NEXT
END IF
END FUNCTION
Private function getUpdateColumnText () AS String
DIM text as string = "" "
For Each Coluna as DataGridColumn in DataGrid1.columns
IF (coluna.gettype (). Name.Equals ("EditCommandColumn")).
DIM colunaedit as editcommandcolumn = ctype (coluna, editcommandcolumn)
Text = colunaedit.Updatetext
EXIT for
END IF
NEXT
Return TEXT
END FUNCTION