Home All Groups Group Topic Archive Search About

custom button/link in detailsview commandfield section

Author
11 Apr 2006 1:47 PM
mt
Hi,

Is it possible to add a button or a link to to the detailsview commandfield
section (where the new, insert, cancel) buttons are displayed.

I've added a button column to the detailsview but it is displayed on a
separate row. Instead I would like to have this button on the same row as the
command fields.

Any help is appreciated.

Thanks

Author
11 Apr 2006 2:14 PM
Phillip Williams
If you want to customize this row then instead of using the CommandField use
a TemplateField where you define any or all of the ItemTemplate,
EditItemTemplate or  InsertItemTemplate as required. 

In each template you can add LinkButtons with the desired CommandNames for
each template.  For example, within the ItemTemplate, you would add:

<asp:LinkButton Text="Edit" runat="server" ID="Edit"
                     CommandName="Edit"></asp:LinkButton>
<asp:LinkButton Text="Insert" runat="server" ID="Insert"
                     CommandName="New"></asp:LinkButton>

In the EditItemTemplate, you would add:

<asp:LinkButton ID="UpdateButton" runat="server" CommandName="Update"
Text="Update"></asp:LinkButton>
<asp:LinkButton ID="btnCancel" CausesValidation="false" runat="server"
CommandName="Cancel" Text="Cancel"></asp:LinkButton>

and in the InsertItemTemplate you would add:

<asp:LinkButton ID="btnInsert" runat="server" CommandName="Insert"
Text="Insert"></asp:LinkButton>
<asp:LinkButton ID="btnCancel" runat="server" CausesValidation="false"
CommandName="Cancel" Text="Cancel"></asp:LinkButton>

This would mimic the action performed by the CommandField (which renders all
those buttons for you based on which property you set to true (e.g.
ShowEditButton=true would render the LinkButton with CommandName="Edit" that
we did above)

But by doing this in templates you get the opportunity to customize the
layout of the DetailsView where you can add now within that templateField the
Button or Link that you asked to add.
Show quoteHide quote
"mt" wrote:

> Hi,
>
> Is it possible to add a button or a link to to the detailsview commandfield
> section (where the new, insert, cancel) buttons are displayed.
>
> I've added a button column to the detailsview but it is displayed on a
> separate row. Instead I would like to have this button on the same row as the
> command fields.
>
> Any help is appreciated.
>
> Thanks
Author
11 Apr 2006 2:58 PM
mt
Thank you.

Show quoteHide quote
"Phillip Williams" wrote:

> If you want to customize this row then instead of using the CommandField use
> a TemplateField where you define any or all of the ItemTemplate,
> EditItemTemplate or  InsertItemTemplate as required. 
>
> In each template you can add LinkButtons with the desired CommandNames for
> each template.  For example, within the ItemTemplate, you would add:
>
> <asp:LinkButton Text="Edit" runat="server" ID="Edit"
>                      CommandName="Edit"></asp:LinkButton>
> <asp:LinkButton Text="Insert" runat="server" ID="Insert"
>                      CommandName="New"></asp:LinkButton>
>
> In the EditItemTemplate, you would add:
>
> <asp:LinkButton ID="UpdateButton" runat="server" CommandName="Update"
> Text="Update"></asp:LinkButton>
> <asp:LinkButton ID="btnCancel" CausesValidation="false" runat="server"
> CommandName="Cancel" Text="Cancel"></asp:LinkButton>
>
> and in the InsertItemTemplate you would add:
>
> <asp:LinkButton ID="btnInsert" runat="server" CommandName="Insert"
> Text="Insert"></asp:LinkButton>
> <asp:LinkButton ID="btnCancel" runat="server" CausesValidation="false"
> CommandName="Cancel" Text="Cancel"></asp:LinkButton>
>
> This would mimic the action performed by the CommandField (which renders all
> those buttons for you based on which property you set to true (e.g.
> ShowEditButton=true would render the LinkButton with CommandName="Edit" that
> we did above)
>
> But by doing this in templates you get the opportunity to customize the
> layout of the DetailsView where you can add now within that templateField the
> Button or Link that you asked to add.
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "mt" wrote:
>
> > Hi,
> >
> > Is it possible to add a button or a link to to the detailsview commandfield
> > section (where the new, insert, cancel) buttons are displayed.
> >
> > I've added a button column to the detailsview but it is displayed on a
> > separate row. Instead I would like to have this button on the same row as the
> > command fields.
> >
> > Any help is appreciated.
> >
> > Thanks