Need help applying a stylesheet to a pushbutton control in a datagrid

T

Tim Meagher

Can anyone help me figure out how to apply a stylesheet to a pushbutton
defined in the asp:BoundColumn or asp:EditCommandColumn elements of a
datagrid?
 
G

Guest

Hi Tim,
Yeah thats a good Question to ask here i did ask a similar Question but no
replies..
Anyway I tried doing this :-

<asp:EditCommandColumn
HeaderText="Editing"
EditText="<input type=submit value=edit style='color:Red'>"
UpdateText="Update"
CancelText="Cancel"
ButtonType="LinkButton"/>
I changed the PushButton to LinkButton but when i applied it
it the event stopped firing!
Let me know how u go..
Patrick
 
S

Scott Mitchell [MVP]

T

Tim Meagher

Hi folks,

I found a simpler way based on another suggestion I ran across. If you
go into the property builder for the datagrid and selection the column
that contains the pushbutton, then you can select at the bottom of the
property builder to change the column to a template. In the template,
the button will be of type "asp:Button" (instead of asp:BoundColumn) to
which you can simply
add the cssClass attribute and specify an external stylesheet.

Here are examples of the result of converting select, remove, edit,
update, cancel, and an editable column to templates and applying the
pertinent cssClass as defined in my external stylesheet:

1. Example of editItem textbox converted to a template
(in the ItemTemplate it is represented by a label,
but in the EditItemTemplate it is represented by a
textbox):

<asp:TemplateColumn HeaderText="Hours">
<ItemTemplate>
<asp:Label CssClass="label" runat="server"
Text='<%# DataBinder.Eval(Container,
"DataItem.Hours") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox CssClass="textbox" runat="server"
Text='<%# DataBinder.Eval(Container,
"DataItem.Hours") %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>


2. Example of edit/update/cancel push buttons that
were converted into a template:

<asp:TemplateColumn>
<ItemTemplate>
<asp:Button CssClass="datagrid" runat="server"
Text="Edit" CommandName="Edit"
CausesValidation="false">
</asp:Button>
</ItemTemplate>
<EditItemTemplate>
<asp:Button CssClass="datagrid" runat="server"
Text="Update" CommandName="Update">
</asp:Button>&nbsp;
<asp:Button CssClass="datagrid" runat="server"
Text="Cancel" CommandName="Cancel"
CausesValidation="false">
</asp:Button>
</EditItemTemplate>
</asp:TemplateColumn>


3. Example of a delete push button that was
converted into a template:

<asp:TemplateColumn>
<ItemTemplate>
<asp:Button CssClass="datagrid" runat="server"
Text="Remove" CommandName="Delete"
CausesValidation="false">
</asp:Button>
</ItemTemplate>
</asp:TemplateColumn>


4. Example of a select push button that was
converted into a template:

<asp:TemplateColumn>
<ItemTemplate>
<asp:Button CssClass="datagrid" runat="server"
Text="Add" CommandName="Select"
CausesValidation="false">
</asp:Button>
</ItemTemplate>
</asp:TemplateColumn>


The Lord Reigns!
 
N

naija naija

Hi Tim,
I tried using ur style in a datagrid but no luck!
Can you give me a hint how i can apply Style to the PushButton below (My
code below)
The Columns are in a Datagrid
Thanks
** Guess 'd understand it better!
:-

<Columns>
<asp:BoundColumn
HeaderText="FileCategoryID"
DataField="FileCategoryID"/>
<asp:BoundColumn
HeaderText="ParentID"
DataField="ParentID"/>

<asp:BoundColumn
HeaderText="FileCategory"
DataField="FileCategory"/>
<asp:BoundColumn
HeaderText="NavigateUrl"
DataField="NavigateUrl"/>
<asp:BoundColumn
HeaderText="target"
DataField="target"/>
<asp:EditCommandColumn
HeaderText="Editing"
EditText="Edit"
UpdateText="Update"
CancelText="Cancel"
ButtonType="PushButton" />

</Columns>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top