Home All Groups Group Topic Archive Search About

Datagrid - How to format EditCommandColumn?

Author
14 Jun 2005 5:56 PM
corndog
I have a Datagrid control with an edit command column, which has a
PushButton ButtonType.

I am trying to apply formatting to the button, to set the font-size and the
font name.

I have only been able to come up with the following...

<asp:EditCommandColumn ButtonType="PushButton" UpdateText="Update"
CancelText="Cancel" EditText="Edit">
<HeaderStyle Width="10%"></HeaderStyle>
<ItemStyle Font-Names="Verdana" Font-Size="8pt"></ItemStyle>
</asp:EditCommandColumn>

This however applies formatting to the cell that the button is contained
in, not the button.  Is there any way to do this?

Author
14 Jun 2005 6:25 PM
Harolds
Use the datagrids ItemDataBound, below is a sample where I get the control
and change the text:
  Private Sub grd_ItemDataBound(ByVal sender As System.Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
grdIncidentSearch.ItemDataBound
    If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
ListItemType.AlternatingItem Then
      Dim lnk As LinkButton = e.Item.FindControl("ControlName")
      lnk.Text = "text"
    End If
  End Sub
Author
14 Jun 2005 6:53 PM
corndog
But the EditCommandColumn does not have an "id" property for its button so I
don't believe the FindControl method can be used.

Show quoteHide quote
"Harolds" wrote:

> Use the datagrids ItemDataBound, below is a sample where I get the control
> and change the text:
>   Private Sub grd_ItemDataBound(ByVal sender As System.Object, ByVal e As
> System.Web.UI.WebControls.DataGridItemEventArgs) Handles
> grdIncidentSearch.ItemDataBound
>     If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
> ListItemType.AlternatingItem Then
>       Dim lnk As LinkButton = e.Item.FindControl("ControlName")
>       lnk.Text = "text"
>     End If
>   End Sub
>
Author
14 Jun 2005 7:06 PM
Harolds
Use a template column

Show quoteHide quote
"corndog" wrote:

> But the EditCommandColumn does not have an "id" property for its button so I
> don't believe the FindControl method can be used.
>
> "Harolds" wrote:
>
> > Use the datagrids ItemDataBound, below is a sample where I get the control
> > and change the text:
> >   Private Sub grd_ItemDataBound(ByVal sender As System.Object, ByVal e As
> > System.Web.UI.WebControls.DataGridItemEventArgs) Handles
> > grdIncidentSearch.ItemDataBound
> >     If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
> > ListItemType.AlternatingItem Then
> >       Dim lnk As LinkButton = e.Item.FindControl("ControlName")
> >       lnk.Text = "text"
> >     End If
> >   End Sub
> >