|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
custom button/link in detailsview commandfield sectionHi,
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 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 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
Other interesting topics
return url value
Show ***** only if have a password How do I debug apsx pages? Datagrid custom paging always loads page 1 Validation inside composite controls for ASP .NET 2.0 Datagrid cancel command does not work when adding new record How to set default values for fields in detailsview problem traping event in child control Webcontrol Alignment problem style question |
|||||||||||||||||||||||