GetType DataGridLinkButton

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.
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top