GetType DataGridLinkButton

  • Thread starter Thread starter rn5a
  • Start date Start date
R

rn5a

In a DataGrid, I am using the following code in the ItemCommand event
of the DataGrid to find if there is a DataGridLinkButton in the row
which is currently in the editable mode:

Sub MyDG_ItemCommand(....)
Dim ctrl As Control
Dim baby As Control
Dim dgi As DataGridItem

For Each dgi In MyDG.Items
If (dgi.ItemType = ListItemType.EditItem) Then
For Each ctrl In dgi.Controls each ctrl will be a
TableCell
For Each baby In ctrl.Controls 'each baby will be the
Controls in each TableCell
If (baby.GetType =
GetType(System.Web.UI.WebControls.DataGridLinkButton)) Then
Response.Write("Type: " &
baby.GetType.ToString & "<br>")
End If
Next
Next
End If
Next
End Sub

Note the If condition just above the Response.Write line. That If
condition generates this error:

Type 'System.Web.UI.WebControls.DataGridLinkButton' is not defined.

How do I overcome this error?

I want the Response.Write line to get executed if & only if the
control within a TableCell happens to be a DataGridLinkButton.
 
In a DataGrid, I am using the following code in the ItemCommand event
of the DataGrid to find if there is a DataGridLinkButton in the row
which is currently in the editable mode:

Sub MyDG_ItemCommand(....)
Dim ctrl As Control
Dim baby As Control
Dim dgi As DataGridItem

For Each dgi In MyDG.Items
If (dgi.ItemType = ListItemType.EditItem) Then
For Each ctrl In dgi.Controls each ctrl will be a
TableCell
For Each baby In ctrl.Controls 'each baby will be the
Controls in each TableCell
If (baby.GetType =
GetType(System.Web.UI.WebControls.DataGridLinkButton)) Then
Response.Write("Type: " &
baby.GetType.ToString & "<br>")
End If
Next
Next
End If
Next
End Sub

Note the If condition just above the Response.Write line. That If
condition generates this error:

Type 'System.Web.UI.WebControls.DataGridLinkButton' is not defined.

How do I overcome this error?

I want the Response.Write line to get executed if & only if the
control within a TableCell happens to be a DataGridLinkButton.

Use GetType(LinkButton) instead
 
Back
Top