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 8462179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:05:47+00:00 2026-06-10T14:05:47+00:00

How to you link the id of the row in GridView to the deletecommand

  • 0

How to you link the id of the row in GridView to the deletecommand so to delete a row?

Here is my code:

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AllowSorting="True" DataSourceID="SqlDataSource1" 
        AutoGenerateColumns="False">
    <Columns>
        <asp:CommandField ShowDeleteButton="True" />
        <asp:BoundField DataField="SDate" HeaderText="SDate" SortExpression="SDate" />
        <asp:BoundField DataField="STime" HeaderText="STime" SortExpression="STime" />
        <asp:BoundField DataField="SPrice" HeaderText="SPrice" 
                SortExpression="SPrice" />
        <asp:BoundField DataField="SDuration" HeaderText="SDuration" 
                SortExpression="SDuration" />
        <asp:BoundField DataField="SNoPlaces" HeaderText="SNoPlaces" 
                SortExpression="SNoPlaces" />
        <asp:BoundField DataField="ScheduleId" HeaderText="ScheduleId" 
                InsertVisible="False" ReadOnly="True" SortExpression="ScheduleId" />
    </Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ChinatowndbConnString %>" 
        DeleteCommand="DELETE FROM Schedule WHERE (ScheduleId = @ScheduleId)" 
        SelectCommand="SELECT SDate, STime, SPrice, SDuration, SNoPlaces, ScheduleId FROM Schedule">
    <DeleteParameters>
        <asp:Parameter Name="ScheduleId" />
    </DeleteParameters>
</asp:SqlDataSource>

I am using Visual Studio 2010.

  • 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-06-10T14:05:49+00:00Added an answer on June 10, 2026 at 2:05 pm

    You forgot to set the DataKeyNames property on the GridView control.

    Change your GridView like:

    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AllowSorting="True" DataSourceID="SqlDataSource1" 
        AutoGenerateColumns="False"
        DataKeyNames="ScheduleId" >
    

    For another example: SqlDataSource.DeleteCommand Property

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<asp:GridView ID=GridView1 runat=server AutoGenerateColumns=False BackColor=White BorderColor=#CC9966 BorderStyle=None BorderWidth=1px CellPadding=4> <Columns> <asp:BoundField DataField=FileID HeaderText=FileID />
<asp:GridView ID=Grid_Organisationtable runat=server CssClass=string SelectedIndex=0 DataKeyNames=OrganisationID ShowHeaderWhenEmpty=True OnRowDeleting=Grid_Organisationtable_RowDeleting OnRowEditing=Grid_Organisationtable_RowEditing AutoGenerateColumns=false Height=95px Width=492px> <Columns> <asp:TemplateField
I have a gridview control with delete asp:ImageButton for each row of the grid.
I have this gridview: <div class=content> <asp:GridView ID=DocumentGrid runat=server AutoGenerateColumns=False OnRowCommand=DocumentGrid_RowCommand > <Columns> <asp:BoundField
I have a Datagrid which looks as under <asp:GridView ID=dgTask runat=server Width=100% AutoGenerateColumns=False> <Columns>
I have the following structure in an aspx page: <asp:Panel ID=pnlCust runat=server> <asp:GridView ID=gvMaster
i have a databound GridView in asp.net 2.0 with a row-selection link. When a
I have a GridView with a ButtonField of type link <asp:ButtonField ButtonType=Link CommandName=more HeaderText=Name
I want to show Delete link in GridView to registred users , therefore I
I have a GridView and Edit link for each row. I can click on

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.