CSSClass of edit button in grid

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

Hi - I'd like to change the cssclass of the edit/update/cancel buttons
on my datagrid, but I haven't been able to figure it out - (code below
does not work) - problem is, I'm not sure how to reference the buttons,
as the column they're in may change in the datagrid depending on the
user.

Thanks for any help,

Sub dgUserList_ItemCreated(ByVal sender As Object, ByVal e As
DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.EditItem Then
e.Item.CssClass = "btn"
End If
End Sub
 
You need to break into the item itself to apply a style to the input tag (ie. e.Item.Controls and
look for the control you want to style). An alternative would be to subclass the Button class and
stick the style in the ctor, replace the Button in your grid with the new Button subclass and you
could avoid having to deal with the ItemCreated stuff.

You might first try to add a CssClass to the table and then create a selector in your stylesheet
that matches the input tag (this is can be troublesome depending upon your entire HTML page
structure and various browsers, plus the input tag covers a lot of territory). So a selector might
look like:

table.GridCss input {
/* style */
}
 
Back
Top