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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:24:14+00:00 2026-05-27T07:24:14+00:00

I am having some problems passing parameters to a DELETE command, and cant seem

  • 0

I am having some problems passing parameters to a DELETE command, and cant seem to get a good understanding on how it works.

<asp:SqlDataSource ID="sdsPropertyList"
    runat="server"
    ProviderName="<%$ appSettings:ProviderName %>"
    ConnectionString="<%$ appSettings:ConnectionString %>"
    SelectCommand="selPropertyByAcntID"
    SelectCommandType="StoredProcedure"
    OnSelecting="sdsPropertyList_Selecting"
    OnSelected="sdsPropertyList_Selected" 
    DeleteCommand="delPropertyByPropID" 
    DeleteCommandType="StoredProcedure"
    OnDeleting="sdsPropertyList_Deleting"
    OnDeleted="sdsPropertyList_Deleted">
    <SelectParameters>
        <asp:Parameter Name="in_acntID" Type="Int32" DefaultValue="0" />
    </SelectParameters>
    <DeleteParameters>
        <asp:Parameter Name="in_acntID" Type="Int32" DefaultValue="0" />
        <asp:Parameter Name="in_propID" Type="Int32" DefaultValue="0" />
    </DeleteParameters>
</asp:SqlDataSource>

<asp:GridView ID="gvProperty" runat="server" DataSourceID="sdsPropertyList" 
    AutoGenerateColumns="false" CssClass="gvPropList">
    <Columns>
        <asp:BoundField HeaderText="ID" InsertVisible="true" DataField="prop_id" ReadOnly="true" Visible="False" />
        <asp:BoundField HeaderText="Property" DataField="prop_title" 
            ItemStyle-CssClass="gvPropTitle" >
        <ItemStyle CssClass="gvPropTitle" />
        </asp:BoundField>
        <asp:BoundField HeaderText="Units" DataField="unitCount" 
            ItemStyle-CssClass="gvUnitCount" >
        <ItemStyle CssClass="gvUnitCount" />
        </asp:BoundField>
        <asp:BoundField DataField="prop_lastmodified" HeaderText="Last Modified" 
            ItemStyle-CssClass="gvDate" DataFormatString="{0:M/dd/yyyy hh:mm tt}" >
        <ItemStyle CssClass="gvDate" />
        </asp:BoundField>
        <asp:TemplateField>
            <ItemTemplate>
                <asp:LinkButton ID="lbtnEdit" runat="server" CommandName="EditRecord" Text="Edit" CommandArgument='<%# Eval("prop_id") %>'></asp:LinkButton>
                <asp:LinkButton ID="lbtnDelete" runat="server" CommandName="Delete" Text="Delete" CommandArgument='<%# Eval("prop_id") %>'></asp:LinkButton>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField>
            <ItemTemplate>
                <asp:LinkButton ID="lbtnAdd" runat="server" CommandName="AddRecord" Text="Add" CommandArgument='<%# Eval("prop_id") %>'></asp:LinkButton>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
    <HeaderStyle CssClass="headerPropList"/>
    <RowStyle CssClass="gvPropRow" />
</asp:GridView>

protected void sdsPropertyList_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
    {
        int userID = Convert.ToInt32(Page.User.Identity.Name);
        if (userID != 0)
            e.Command.Parameters["in_acntID"].Value = userID;
    }

protected void sdsPropertyList_Deleting(object sender, SqlDataSourceCommandEventArgs e)
    {
        int userID = Convert.ToInt32(Page.User.Identity.Name);
        if (userID != 0)
        {
            e.Command.Parameters["in_acntID"].Value = userID;
        }
    }

The SELECT statement is straightforward which requires one input parameter of userID.
However, the DELETE statement, requires 2 parameter inputs.
in_acntID = userID
in_propID = the boundfield datafield prop_id

What am I doing wrong? and should the CommandName and CommandArgument be passed at the ItemTemplate level if I have it defined at the SqlDataSource level?

I want the delete button to achieve the following:

  1. delete records from table(s) in DB
  2. remove the row from the gridview

UPDATE

After some additional research, I’ve found that, the NAME for parameters and HeaderText for Boundfield must be the same so that the values within your gridview can be used by the SQL commands of the datasource.

With the exception of the initial select commant, i have removed all the code behind references.

All is working corrently now.

  • 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-27T07:24:14+00:00Added an answer on May 27, 2026 at 7:24 am

    After some additional research, I’ve found that, the NAME for parameters and HeaderText for Boundfield must be the same so that the values within your gridview can be used by the SQL commands of the datasource.

    With the exception of the initial select commant, i have removed all the code behind references.

    All is working corrently now.

    <asp:SqlDataSource ID="sdsPropertyList"
        runat="server"
        ProviderName="<%$ appSettings:ProviderName %>"
        ConnectionString="<%$ appSettings:ConnectionString %>"
        SelectCommand="selPropertyByAcntID"
        SelectCommandType="StoredProcedure"
        OnSelecting="sdsPropertyList_Selecting"
        DeleteCommand="delPropertyByPropID" 
        DeleteCommandType="StoredProcedure"
        OnDeleted="sdsPropertyList_Deleted" >
        <SelectParameters>
            <asp:Parameter Name="acnt_id" Type="Int32" />
        </SelectParameters>
        <DeleteParameters>
            <asp:Parameter Name="acnt_id" Type="Int32" />
            <asp:Parameter Name="prop_id" Type="Int32" />
        </DeleteParameters>
    </asp:SqlDataSource>
    <asp:GridView ID="gvProperty" runat="server" DataSourceID="sdsPropertyList" 
        AutoGenerateColumns="false" CssClass="gvPropList" DataKeyNames="acnt_id, prop_id">
        <Columns>
            <asp:BoundField HeaderText="acnt_id" InsertVisible="true" DataField="acnt_id" ReadOnly="true" Visible="False" />
            <asp:BoundField HeaderText="prop_id" InsertVisible="true" DataField="prop_id" ReadOnly="true" Visible="False" />
            <asp:BoundField HeaderText="Property" DataField="prop_title">
            <ItemStyle CssClass="gvPropTitle" />
            </asp:BoundField>
            <asp:BoundField HeaderText="Units" DataField="unitCount" >
            <ItemStyle CssClass="gvUnitCount" />
            </asp:BoundField>
            <asp:BoundField DataField="prop_lastmodified" HeaderText="Last Modified" 
                ItemStyle-CssClass="gvDate" DataFormatString="{0:M/dd/yyyy hh:mm tt}" >
            <ItemStyle CssClass="gvDate" />
            </asp:BoundField>
            <asp:BoundField HeaderText="Active" DataField="prop_active">
            <ItemStyle CssClass="gvPropActive" />
            </asp:BoundField>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:LinkButton ID="lbtnEdit" runat="server" CommandName="EditRecord" Text="Edit"></asp:LinkButton>
                    <asp:LinkButton ID="lbtnDelete" runat="server" CommandName="Delete" Text="Delete"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:LinkButton ID="lbtnAdd" runat="server" CommandName="AddRecord" Text="Add"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <HeaderStyle CssClass="headerPropList"/>
        <RowStyle CssClass="gvPropRow" />
    </asp:GridView>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some problems with Jquery UI Dialog and TinyMCE. Passing data to a
I have been having some problems trying to get my PHP running. When I
I'm having some problems passing an integer array to an MVC controller. I'm grabbing
I'm having some problems in passing context from the app delegate to the view
I am having some problems with null values Is there a good way of
I am having some problems parsing this piece of XML using SimpleXML. There is
Currently having some problems- now = datetime.datetime.now() month = now.strftime(%B) site = wikipedia.getSite('en', 'wikiquote')
Im having some problems getting the Sticky Footer to work on my site. If
I'm having some problems integrating MS MapPoint 2009 into my WinForms .Net 2.0 application
I'm having some problems with the ranking used by fulltext search in SQL Server.

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.