How to show insert or cancel buttons instead of links with Detailsview?

How to show insert or cancel buttons instead of links with Detailsview?

0


a source to share


2 answers


You can use CommandField inside tag <fields>



        <Fields>
            <asp:CommandField ButtonType="Button" />
        </Fields>

      

+1


a source


Moved to this question looking for some other DetailsView information. An alternative approach to the above is to change the command field in the template field (in the Edit Fields dialog box to present details, select the command field entry in the list of selected fields, then click Convert this field to template field). 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" />&nbsp;
             <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>

      



There will now be ItemTemplate and EditItemTemplate items, but you get the idea. I've changed the default asp: LinkButton setting for ImageButtons, but you can also use regular buttons regardless of your UI design. The important part is the CommandName entry for each control - be it insert, update, delete, cancel - this is the command name that invokes the corresponding operation.

Hope you can get more help.

+1


a source







All Articles