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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:42:35+00:00 2026-06-12T14:42:35+00:00

Currently, when a user clicks on anywhere on a row, it selects that row.

  • 0

Currently, when a user clicks on anywhere on a row, it selects that row. Unfortunately, when in edit mode (after clicking on “edit’), the form does a postback every time a user clicks anywhere on the form. How do I disable this and let the user edit the row in peace?

This is what I have that enables click to select row:

protected void GridView1_RowCreated(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            List<int> notClickable = new List<int>();
            {
                notClickable.Add(0);
            }

            for (int i = 0; i < e.Row.Cells.Count; i++)
            {
                if (!notClickable.Contains(i))
                {
                    e.Row.Cells[i].Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink(this.GridView1, "Select$" + e.Row.RowIndex);
                    e.Row.Cells[i].Attributes["onclick"] = this.Page.ClientScript.GetPostBackClientHyperlink(this.GridView1, "Select$" + e.Row.RowIndex);
                }
            }

            e.Row.Attributes.Add("onmouseover", "this.originalstyle=this.style.backgroundColor;this.style.backgroundColor='#ceedfc'");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalstyle");
            e.Row.Attributes.Add("style", "cursor:pointer;");
            e.Row.ToolTip = "Click to select row";
        }
    }

Revised code that solves the problem:

protected void GridView1_RowCreated(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (GridView1.EditIndex != -1)
            {
                e.Row.Attributes.Remove("onmouseover");
            }
            else
            {
                List<int> notClickable = new List<int>();
                {
                    notClickable.Add(0);
                }

                for (int i = 0; i < e.Row.Cells.Count; i++)
                {
                    if (!notClickable.Contains(i))
                    {
                        e.Row.Cells[i].Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink(this.GridView1, "Select$" + e.Row.RowIndex);
                        e.Row.Cells[i].Attributes["onclick"] = this.Page.ClientScript.GetPostBackClientHyperlink(this.GridView1, "Select$" + e.Row.RowIndex);
                    }
                }

                e.Row.Attributes.Add("onmouseover", "this.originalstyle=this.style.backgroundColor;this.style.backgroundColor='#ceedfc'");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalstyle");
                e.Row.Attributes.Add("style", "cursor:pointer;");
                e.Row.ToolTip = "Click to select row";
            }
        }
    }
  • 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-12T14:42:36+00:00Added an answer on June 12, 2026 at 2:42 pm

    On your select function, have it remove the onclick attributes. Then when you are done editing, add it back.

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

Sidebar

Related Questions

I'm currently building a user control that displays a message when a Repeater is
I currently have an activity model that handles a user activity notification system. An
I have a site where the user currently selects an option (event) from a
In my ASP.Net application I have a requirement that when a user clicks on
I have a select dropdown and if a user clicks 'outside' of that select
Context: User is currently in the following page: http://myinternaldomain.com/page/ Issue: When user clicks on
I'm currently showing the user a pop-up form - http://colorpowered.com/colorbox/ - which so far
I currently making a filebrowser. If the user clicks on a link to a
Goal: Once i click on the start button on my user interface, i currently
I'm currently using: @user = User.find(params[:id]) @posts = Post.find(:all, :conditions => [user_id = ?,

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.