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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:02:14+00:00 2026-06-02T16:02:14+00:00

I have a gridview that it bind to a data table.I want to add

  • 0

I have a gridview that it bind to a data table.I want to add context ment for rows that has a condition. I use this code in RowDataBound event:

if (e.Row.Enabled == true && e.Row.Cells[6].Enabled == true)
        {
            e.Row.CssClass = "HasMenu";
        }

now I write this code to show context menu on grid:

$(document).ready(function () {

        $('#menu').click(function () {
            $('#menu').hide();
        });
        $(document).click(function () {
            $('#menu').hide();
        });


        $("#" + '<%= GridView1.ClientID %>').bind("contextmenu", function (e) {
            $('#menu').css({
                top: e.pageY + 'px',
                left: e.pageX + 'px'
            }).show();

            return false;

        });
    });

the problem is I don’t show any context menu(not explorer context menu and not my custom context menu) on the rows that has no HasMenu css class and show Context menu for rows that has HasMenu css class .what change need on my script?

thanks

  • 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-02T16:02:15+00:00Added an answer on June 2, 2026 at 4:02 pm

    Right now you’re listening to the contextmenu event for the entire gridview:

    $("#" + '<%= GridView1.ClientID %>')
    

    You’d need to change that to individual rows:

    $('#" + '<%= GridView1.ClientID %> rowselector.HasMenu')
    

    Where rowselector is however a row is defined in your markup.

    For instance, if a row is a <TR> then you would write

    $("#" + '<%= GridView1.ClientID %> tr.HasMenu')
    

    Otherwise, if the rows are child <DIV> elements you might want to write something like

    $("#" + '<%= GridView1.ClientID %> > div.HasMenu')
    

    Note that you’re concatenating two plain strings, there’s no javascript variables involved. You might as well write:

    $('#<%= GridView1.ClientID %> rowselector.HasMenu')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background I have a GridView that builds a table using an ObjectDataSource . This
I have developed an asp.net application that has a Gridview control. I want it
I have a simple gridview: A sql datasource to bind data from table data
I have a GridView to which I bind a dataTable that I manually created.
I have a GridView that I would like to bind to an ObjectDataSource. I
I have a gridview that is bind to the datatable. how to programmaticaly change
I have a gridview that binds its rows from an objects method: public DataSet
I'm using a gridview and SqlDataSource to bind the data table information to the
I have an ASP.NET GridView that uses an EmptyDataTemplate. This template is used to
I am new in C#.I want to add rows in a GridView in runtime.

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.