Dim i As IntegerFor i = 0 To tGrid.Columns.Count - 1 Dim tColumn As DataControlField = tGrid.Columns(i) If Not TypeOf (tColumn) Is CommandField Then Continue For Dim tCommand As CommandField = DirectCast(tColumn, CommandField) If Not tCommand.ShowDeleteButton Then Continue For Dim tRow As GridViewRow For Each tRow In tGrid.Rows Dim tControl As Control For Each tControl In tRow.Cells(i).Controls If Not TypeOf (tControl) Is IButtonControl Then Continue For If DirectCast(tControl, IButtonControl).CommandName <> "Delete" Then Continue For ' ここはLinkButton決め打ちだけど、Link以外にも対応したい場合は、追加かな。 DirectCast(tControl, LinkButton).OnClientClick = "return confirm('削除してもよろしいですか?');" Next NextNext