Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 209779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:56:46+00:00 2026-05-11T17:56:46+00:00

Currently I have a DetailsView attached to a GridView. When you select an item

  • 0

Currently I have a DetailsView attached to a GridView. When you select an item from the GridView the details show up in the DetailsView (duh). Right now there are 3 event options on the DetailsView: Edit, Delete, and New. I would like to add a 4th, Format. This will simply run some queries and then perform a delete. Is this possible and how?

Another possibility would be to add this event to the GridView instead (maybe while in Edit mode?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:56:46+00:00Added an answer on May 11, 2026 at 5:56 pm

    If you add your own buttons to the DetailsView as suggested you can hook the ItemCommand event on the DetailsView and add any logic for each CommandName in the ItemCommand method

    <%@ Page Language="C#" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">
    
        void CustomerDetailView_ItemCommand(Object sender, DetailsViewCommandEventArgs e)
        {
    
            // Use the CommandName property to determine which button
            // was clicked. 
            if (e.CommandName == "Add")
            {
    
                // Add the current store to the contact list. 
    
                // Get the row that contains the store name. In this
                // example, the store name is in the second row (index 1)  
                // of the DetailsView control.
                DetailsViewRow row = CustomerDetailView.Rows[1];
    
                // Get the store's name from the appropriate cell.
                // In this example, the store name is in the second cell  
                // (index 1) of the row.
                String name = row.Cells[1].Text;
    
                // Create a ListItem object with the store's name.
                ListItem item = new ListItem(name);
    
                // Add the ListItem object to the ListBox, if the 
                // item doesn't already exist.
                if (!ContactListBox.Items.Contains(item))
                {
                    ContactListBox.Items.Add(item);
                }
    
            }
    
        }
    
    </script>
    
    <html  >
    <head runat="server">
        <title>
                DetailsView ItemCommand Example</title>
    </head>
    <body>
        <form id="Form1" runat="server">
            <h3>
                DetailsView ItemCommand Example</h3>
            <asp:DetailsView ID="CustomerDetailView" 
                DataSourceID="DetailsViewSource"
                AutoGenerateRows="false" 
                DataKeyNames="CustomerID" 
                AllowPaging="true" 
                OnItemCommand="CustomerDetailView_ItemCommand"
                runat="server">
    
                <FieldHeaderStyle BackColor="Navy" ForeColor="White" />
    
                <Fields>
                    <asp:BoundField DataField="CustomerID" HeaderText="Store ID" />
                    <asp:BoundField DataField="CompanyName" HeaderText="Store Name" />
                    <asp:BoundField DataField="City" HeaderText="City" />
                    <asp:ButtonField CommandName="Add" Text="Add Contact" />
                </Fields>
            </asp:DetailsView>
    
            <hr />
    
            Contacts:<br />
            <asp:ListBox ID="ContactListBox" runat="server" />
            <!-- This example uses Microsoft SQL Server and connects  -->
            <!-- to the Northwind sample database. Use an ASP.NET     -->
            <!-- expression to retrieve the connection string value   -->
            <!-- from the web.config file.                            -->
            <asp:SqlDataSource ID="DetailsViewSource" runat="server" 
              ConnectionString=
                "<%$ ConnectionStrings:NorthWindConnectionString%>"
                InsertCommand="INSERT INTO [Customers]([CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country]) VALUES (@CustomerID, @CompanyName, @Address, @City, @PostalCode, @Country)"
              SelectCommand="Select [CustomerID], [CompanyName], 
                [Address], [City], [PostalCode], [Country] From 
                [Customers]">
            </asp:SqlDataSource>
        </form>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a DetailsView in ASP.NET that gets data from the database based
Currently I have a ListView (using the Details View). I would like to implement
I currently have a TableView inside a NavigationController where when a item is selected
I can't seem to bind a single GridView's row to a DetailsView properly. Currently
I currently have an MS Access application that connects to a PostgreSQL database via
I currently have speakers set up both in my office and in my living
I currently have an existing database and I am using the LINQtoSQL generator tool
We currently have a company email server with Exchange, and a bulk email processing
I currently have a fairly robust server-side validation system in place, but I'm looking
I currently have heavily multi-threaded server application, and I'm shopping around for a good

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.