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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:54:50+00:00 2026-06-06T09:54:50+00:00

I know this question had been asked a hundred times, but I have difficulties

  • 0

I know this question had been asked a hundred times, but I have difficulties implementing different solutions.I need to retrieve a selected row from a grid view in asp.net web application C#.I’ve done the databinding.I don’t want to use edit/update buttons or checkboxe/radio button, just to select it by clicking on the row.Please help, I’m a little stuck, and I would like not to implement javascript based solutions.Thanks.

if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("OnMouseOver", "this.style.cursor='pointer';this.style.textDecoration='underline';");
            e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';";
            e.Row.ToolTip = "Click on select row";
            e.Row.Attributes["OnClick"] = Page.ClientScript.GetPostBackClientHyperlink(this.SingleSelectGrid, "Select$" + e.Row.RowIndex);


            LinkButton selectbutton = new LinkButton()
            {
                CommandName = "Select",
                Text = e.Row.Cells[0].Text
            };
            e.Row.Cells[0].Controls.Add(selectbutton);
            e.Row.Attributes["OnClick"] = Page.ClientScript.GetPostBackClientHyperlink(selectbutton, "");


        }
  • 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-06T09:54:51+00:00Added an answer on June 6, 2026 at 9:54 am

    if i get it right, this should do what you want:

    .aspx:

     <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"    
      DataKeyNames="id" onselectedindexchanged="GridView1_SelectedIndexChanged">
    

    code behind:

     protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        int index = Convert.ToInt16(GridView1.SelectedDataKey.Value);
    
    }
    

    this should do what you want..index will give you the selected row ID, provided by the DataKeyNames attribute in your .aspx page. This however does require the “Enable Selection” to be checked. (Go to your .aspx page, designer, click your gridview, you should see the “Enable selection” attribute).

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

Sidebar

Related Questions

I know that this question had been asked many times, but every answer seems
I know that this question had already been asked a couple of times before,
I know this question as been asked countless times, but believe me I've searched
Alright, I know questions like this have probably been asked dozens of times, but
So I know this question have been asked a lot , but I don't
Sorry I know similar question have been asked many times before but like most
I know, variations of this question had been asked before. But my case may
I know this question has been asked several times, but I would like to
I know this question has been asked a couple of times before. I m
I know this question was asked here many times before but I am still

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.