Link to home
Start Free TrialLog in
Avatar of jglazer63
jglazer63

asked on

Resize button in button column

I have datagrid on my page with a button column in column (0) (pushbutton).  I want to change the attributes of the button (font size, box color, etc).  Can anyone help me figure out how to do this?  The code below is from some research but it doesn't seem to make a difference.  (articlelist is my datagrid).

Protected Sub articleList_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles articleList.ItemCreated
        If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then ' suppose the button in last column
            Dim btn As Button = e.Item.Cells(0).Controls(0)
            btn.Font.Name = "verdana"
            btn.Font.Size = 10
        End If
 
    End Sub

Open in new window

Avatar of TheMegaLoser
TheMegaLoser
Flag of Sweden image

Can't you just use the item style property in the declaration instead?

<asp:DataGrid>
  <Columns>
    <asp:ButtonColumn ItemStyle-Font-Size="10" ItemStyle-Font-Names="Verdana"></asp:ButtonColumn>
  </Columns>
</asp:DataGrid>
Avatar of jglazer63
jglazer63

ASKER

Nope, works for buttonlink not buttoncolumn.  Give it a shot.
ASKER CERTIFIED SOLUTION
Avatar of TheMegaLoser
TheMegaLoser
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It works with Itemcreated too.

Code it be that you missed the subtle changes in button layout or is it anything else with your code that crashes it?