I have a ButtonColumn in a DataGrid:
<asp:ButtonColumn HeaderText="Edit" ButtonType="PushButton" Text="Edit" />
How to set CSS class?
The only way I can do this is to hook into the RowDataBound event:
Protected Sub dgSchedule_ItemDataBound(sender As Object, e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgSchedule.ItemDataBound
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
DirectCast(e.Item.Cells(6).Controls(0), Button).CssClass = "confirmButton"
End If
End Sub
I just feel that there needs to be a tidier way. What happens if I add / remove columns, I have to go back here and don't forget to change column 6 ...
I tried to use TemplateColumnregular asp:Button. This worked, but then clicked it so as not to fire the ItemCommand event of the grid that I need to fire.
source
share