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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:20:33+00:00 2026-06-15T15:20:33+00:00

I have a GridView with users and I want to be able to select

  • 0

I have a GridView with users and I want to be able to select the first column of a row – which is with usernames. I know how to do it with the autogenerateselectbutton property, but it doesn’t look well on my design. So instead, I want to make it without the Select button. Here is what I have so far:

<asp:GridView ID="GridView5" AllowPaging="true" GridLines="None" CssClass="mGrid" PagerStyle-CssClass="pgr" AlternatingRowStyle="alt" runat="server" AllowSorting="True"
                            AutoGenerateColumns="False"
                            Width="750px"
                            CausesValidation="False" OnPageIndexChanging="gridView5_PageIndexChanging"  OnSelectedIndexChanged="gridView5_SelectedIndexChanged" autogenerateselectbutton="True" >
                            <Columns>
                                <asp:BoundField DataField="username" HeaderText="Username" ReadOnly="True" />
                                <asp:BoundField DataField="name" HeaderText="Name" />
                                <asp:BoundField DataField="lastname" HeaderText="Last name" />
                            </Columns>
                            <selectedrowstyle backcolor="LightCyan"
     forecolor="DarkBlue"
     font-bold="true"/>  </asp:GridView>

If I remove the autogenerateselectbutton, then clicking on a row does nothing.

Here is my c# code, which takes the value from this cell and stores it into a string and then i call the setUser() function with the cell value as a parameter.

protected void gridView5_SelectedIndexChanged(Object sender, EventArgs e)
{
    GridViewRow row = GridView5.SelectedRow;
    string user = row.Cells[1].Text.ToString();
    setSelectedUser(user);
}

I think the problem is in the aspx file, where I create my GridView, but don’t know how to make the row selectable without the autogenerateselectbutton set to true.

  • 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-15T15:20:34+00:00Added an answer on June 15, 2026 at 3:20 pm

    You want to use the RowCommand method you can create a asp:ButtonField column and set the command name

       protected void GridView1_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
       {
            if (e.CommandName=="MyCommand")
            {    
                 int row = int.Parse(e.CommandArgument.ToString());
                 var cellText= gvOwner.Rows[row].Cells[1].Text.Trim();
            }
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a gridview with a column of checkboxes. I want the user
Have a gridview control which will show X amount of rows. I want to
I have a gridview which I am binding through code behind, I want to
I have a GridView which displays in excess of 30000 rows, and users need
I have a GridView which allows users to enter data using a EmptyDataTemplate. There
I have a gridview that contains data. I want the user to be able
I have a gridview and I have a button on it.I want, if the
I have a GridView and SqlDataSource , I have a column type: DateTime .
I have a gridview where the user will be able to enter values and
I have a CGridView with a CCheckBoxColumn and selectableRows = 2. Users can select

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.