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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:04:31+00:00 2026-06-04T20:04:31+00:00

I have a fairly simple GridView. This is the markup for Columns: <Columns> <asp:TemplateField

  • 0

I have a fairly simple GridView. This is the markup for Columns:

 <Columns>
                <asp:TemplateField HeaderText="JD Name" SortExpression="FullName"
                    HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="180px" >
                    <ItemTemplate>
                        <asp:LinkButton CommandName="edt" CommandArgument='<%#Eval("JurisdictionID") %>' runat="server" Text='<%#Eval("FullName") %>' />
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:BoundField HeaderText="JD Abbreviation" ItemStyle-Width="200px"  DataField="JDAbbreviation" SortExpression="JDAbbreviation"
                    HeaderStyle-HorizontalAlign="Center" />

                 <asp:TemplateField 
                    HeaderStyle-HorizontalAlign="Center" >
                    <ItemTemplate>
                        <asp:LinkButton ID="lnkStat" CommandName="inac" CommandArgument='<%#Eval("JurisdictionID") %>' 
                        runat="server" Text='<%#Utils.GetStatusString((bool) Eval("IsActive")) %>' />
                    </ItemTemplate>
                </asp:TemplateField>

            </Columns>

However, when I click on of the columns for sorting, it first triggers a row command event and then comes to sorting event. Can anybody tell me what is the mistake I am doing? In the RowCommand argument I get the SortExpression. This is really funny for me!

  • 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-04T20:04:33+00:00Added an answer on June 4, 2026 at 8:04 pm

    Sort is a row command. Check out this MSDN GridView.RowCommand Event article for more details.

    In your row command event you should add an if statement so you can determine when the row command code should execute. Use e.CommandName.

    void ContactsGridView_RowCommand(Object sender, GridViewCommandEventArgs e)
    {
      // If multiple buttons are used in a GridView control, use the
      // CommandName property to determine which button was clicked.
      if(e.CommandName=="Add")
      {
        // Convert the row index stored in the CommandArgument
        // property to an Integer.
        int index = Convert.ToInt32(e.CommandArgument);
    
        // Retrieve the row that contains the button clicked 
        // by the user from the Rows collection.
        GridViewRow row = ContactsGridView.Rows[index];
    
        // Create a new ListItem object for the contact in the row.     
        ListItem item = new ListItem();
        item.Text = Server.HtmlDecode(row.Cells[2].Text) + " " +
        Server.HtmlDecode(row.Cells[3].Text);
    
        // If the contact is not already in the ListBox, add the ListItem 
        // object to the Items collection of the ListBox control. 
        if (!ContactsListBox.Items.Contains(item))
        {
          ContactsListBox.Items.Add(item);
        }
      }
    }  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this fairly simple form: <form action=...> <div> <input type=text class=input-text value= name=text
Hopefully this is simple. I have a fairly simple ASP.NET (framework version 2) app
I have a fairly simple block of code. Sub Run(Name) on error resume next
I have a fairly simple ASP.NET 2.0 menu control using a sitemap file and
I have a fairly simple asp grid view, tied to an object data source.
I have fairly simple layout, like this: <div class=card> <span class=attack>1</div> <span class=defence>2</div> </div>
I have this fairly simple function to compute the mean of elements of a
I have a fairly simple system, and for the purposes of this question there
I have a fairly simple iOS 5 app at this point. A UINavigationController is
I have a fairly simple menu: <ul id=menu> <!-- TemplateBeginEditable name=mainmenu --> <li><a href=index.htm

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.