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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:43:33+00:00 2026-05-26T20:43:33+00:00

I have a CommandArgument that takes in 1 argument from a LinkButton in my

  • 0

I have a CommandArgument that takes in 1 argument from a LinkButton in my GridVie for row deletion in GridView.

Code in my aspx.cs:

LinkButton lnk = (LinkButton)sender;
        string stid = lnk.CommandArgument.ToString();
        SqlConnection conn = new SqlConnection("<Connection>");
        string sql = string.Format("DELETE FROM [ConflictingRole] where Role like '%{0}%'",stid);
        SqlCommand cmd = new SqlCommand(sql, conn);
        conn.Open();
        cmd.ExecuteNonQuery();

Code in my .aspx:

<asp:GridView ID="GridView1" ondatabound="gv_DataBound" runat="server" DataSourceID="SqlDataSource1">
    <Columns>
        <asp:TemplateField>
           <ItemTemplate>

             <asp:CheckBox ID="UserSelection" OnCheckedChanged="CRUserSelector_CheckedChanged" ondatabound="gv_DataBound" runat="server" />
             <asp:LinkButton ID="lnkDelete" runat="server" onclick="lnkDelete_Click" Text="Delete" CommandArgument='<%# Eval("Role") %>' PostBackUrl="~/CRList.aspx" ></asp:LinkButton>

           </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

My current CommandArgument only takes in one column name, which is Role. However, I would like to take in 2 column names, and use the 2 column names in my String sql statement in aspx.cs.

Reason: I have multiple rows with the same value of “Row”, thus if I delete based on the “Role” column’s value, I will delete multiple rows. I would want to take in values from both “Role” and “ConflictingRole” for the delete sql query.

May I know if it is possible to do so?

Thank You.

  • 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-26T20:43:34+00:00Added an answer on May 26, 2026 at 8:43 pm

    You may pass value of two or more columns by converting them to string with comma delimiter.

    CommandArgument='<%# Eval("Role") + "," + Eval("ConflictingRole") %>'
    

    split the commandArgument value in the handler,

    string []ar=lnk.CommandArgument.ToString().Split(',');
    

    EDIT:

    You may write delete query like:

    string sql="DELETE FROM [ConflictingRoles] where Role like @role AND ConflictingRole like @crole";
    

    OR

    string sql="DELETE FROM [ConflictingRoles] where Role=@role AND ConflictingRole=@crole";
    

    Or Hard coded sql statement (which is not recommend)

    string sql=string.Format("DELETE FROM [ConflictingRoles] where Role like '%{0}%' AND 
              ConflictingRole like '%{1}%'",ar[0],ar[1]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the the GridView's column looking like that: <Columns> <asp:TemplateField HeaderText=Opcje> <ItemTemplate> <asp:LinkButton
I have Repeater with LinkButton with ID CommandArgument When I click that button, I
Basically I have got two things i am passing from a command argument <asp:LinkButton
so I have a python script which takes the filename as a command argument
SOLVED: See my solution below! using aspx with C# code behind. I have the
I have a link in a Gridview that I want opened in Windows Explorer
I have a GridView containing records from a table which can be deleted or
I have an LinkButton column in my GridView: <Columns> <asp:TemplateField> <ItemTemplate> <asp:LinkButton runat=server/> </ItemTemplate>
I have a User object with a Load method that takes in a UserId
I have a repeater control that generates a list of links from a SqlReader.

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.