Reputation: 74447
How to show insert or cancel buttons instead of links with Detailsview?
Upvotes: 0
Views: 2874
Reputation: 2528
Came across this question while looking for other information on the DetailsView. An alternative approach to that above is to change the commandfield into a template field (from the Edit Fields dialog box for the details view, select the command field entry in the list of selected fields, then click on the "Convert this field into a template field" link). Then, back in your source view, you will see something like this:
<asp:TemplateField HeaderText="Actions">
<InsertItemTemplate>
<asp:ImageButton ID="btnInsertAccept" runat="server" CausesValidation="True" CommandName="Insert" AlternateText="Insert" ImageUrl="images/16x16.check.gif" ToolTip="Click to insert this new division." ValidationGroup="ValidationInsert" />
<asp:ImageButton ID="btnInsertCancel" runat="server" CausesValidation="False" CommandName="Cancel" AlternateText="Cancel" ImageUrl="images/cancel.png" ToolTip="Click to cancel inserting this new division." />
</InsertItemTemplate>
</asp:TemplateField>
Now, there will also be ItemTemplate and EditItemTemplate entries, but you get the idea. Ive changed the default asp:LinkButton controls to ImageButtons, but you could also use normal buttons, whatever fits your UI design. The important part is the CommandName entry on each control - be it insert, Update, Delete, Cancel - it is that command name that causes the appropriate operation to take place.
Hope that give you additional help.
Upvotes: 1
Reputation: 44278
You can use the CommandField inside your <fields>
tag
<Fields>
<asp:CommandField ButtonType="Button" />
</Fields>
Upvotes: 2