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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:12:49+00:00 2026-06-09T13:12:49+00:00

In my application i am using a GridView and i am adding an onlick

  • 0

In my application i am using a GridView and i am adding an onlick attribute to the GridView through the following Code..

  Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)


    If e.Row.RowType = DataControlRowType.DataRow Then
        e.Row.Attributes("onclick") = Page.ClientScript.GetPostBackClientHyperlink(GridView1, "Select$" & e.Row.RowIndex.ToString())
    End If

When someone selects a row in the Grid view, i want the GridView to get disabled and not allow any other selections unless the user presses a button. I tried using

GridView1.Enabled = false

But still the user is able to select a row.

How can i disable the GridView Selection ??

  • 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-09T13:12:50+00:00Added an answer on June 9, 2026 at 1:12 pm

    Since you are selecting a row by the above code the easiest fix would be to check if selected index is not equal to -1 (meaning a row has been selected) in the row databound event.

    If GridView1.SelectedIndex = -1 Then
        If e.Row.RowType = DataControlRowType.DataRow Then
            e.Row.Attributes("onclick") = Page.ClientScript.GetPostBackClientHyperlink(GridView1, "Select$" + e.Row.RowIndex.ToString())
        End If
    End If
    

    and to reattach the selecting code on the click of a button you can just set the selectedIndex to -1 and rebind the gridview in the button click event.

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

Sidebar

Related Questions

Friends, I'm populating a GridView in my asp.net application using following code. GridView grdExport
I am using gridview in my ASP.NET web application and using templatefield to show
I'm developing a web application and I'm using a gridview and sqldatasource. I have
In my WPF application , I am using ListView GridView, and I implemented a
I publish my web application using msbuild by calling following command: msbuild myweb.csproj /T:Package
I am using DevExpress in my winform application, I have a gridview, data entry
i am developing one asp.net application,i am using one gridview and bind the data
I am using VB.net for coding. I am having GridView Control in my application.
I have implement GridView Row Editing feature in my .net application using <asp:CommandField .
Am running asp.net application.I try to build sample site using gridview.I got compilation error

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.