title: How to get cell ID of ASP.NET GridView in jQuery on right Click?
body: <p>I have a GridView in my Application. I need to provide user some functionality to edit some cells or delete rows. I need to show context menu when user right clicks on some cell. When user click "Edit" I need to show some help Info and put this cell in Edit mode and set focus on It. Here is my Code:</p>
  
  <pre><code>&lt;asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server"&gt;
      &lt;script type="text/javascript"&gt;
          $(document).ready(function () {
              $("#myMenu").hide();
              $("#helpRow").hide();
              $("table[id$='gvListOfMatters'] &gt; tbody &gt; tr &gt; td").bind('contextmenu', function (e) {
              $("#myMenu").hide();
              e.preventDefault();
              $(this).css("cursor", "pointer");
              iColIndex = $(this).closest("tr td").prevAll("tr td").length;
              iRowIndex = $(this).closest("tr").prevAll("tr").length;
              rowid = $(this).parent().children()[0].innerHTML;
              if (!isNaN(rowid)) {
                  //call context menu here
                  $("#myMenu").css({
                      top: e.pageY + "px",
                      left: e.pageX + "px",
                      position: 'absolute'
                  });
                  $("#myMenu").show(100);
              }
          });
          });
          //hide when left mouse is clicked
          $(document).bind('click', function (e) {
              $("#myMenu").hide(100);
          });
  
          var rowid = 0;
          function fnEdit() {
              var lnkEdit = document.getElementById('&lt;%=lnkEdit.ClientID %&gt;');
              var hiddenField = document.getElementById('&lt;%=fldRowID.ClientID %&gt;');
              hiddenField.value = rowid;
              lnkEdit.click();
          };
  
          function fnDelete() {
              var lnkDelete = document.getElementById('&lt;%=lnkDelete.ClientID %&gt;');
              var hiddenField = document.getElementById('&lt;%=fldRowID.ClientID %&gt;');
              hiddenField.value = rowid;
              lnkDelete.click();
          };
      &lt;/script&gt;
  
      &lt;div id="helpRow"&gt;
      &lt;/div&gt;
      &lt;asp:GridView ID="gvHelpRow" runat="server" AutoGenerateColumns="true" CssClass="helpRow" ShowHeader="false" Visible="false"&gt;&lt;/asp:GridView&gt;
      &lt;br /&gt;
  
      &lt;div id="SourceGrid" class="table responsive"&gt;
          &lt;asp:GridView ID="gvListOfMatters" runat="server"
          SOME Tamplate COLUMNS…
          &lt;/asp:GridView&gt;
      &lt;/div&gt;
  
      &lt;asp:LinkButton ID="lnkEdit" runat="server" Style="display: none" OnClick="lnkEdit_Click" /&gt;
      &lt;asp:LinkButton ID="lnkDelete" runat="server" Style="display: none" OnClick="lnkDelete_Click" /&gt;
      &lt;asp:HiddenField ID="fldRowID" runat="server" /&gt;
  
      &lt;%--↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ContextMenu↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓--%&gt;
      &lt;div id="myMenu" class="contextMenu"&gt;
          &lt;table style='width: 100%;'&gt;
              &lt;tr&gt;
                  &lt;td onclick="fnEdit();"&gt;- Edit
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td onclick="fnDelete();"&gt;- Delete
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/div&gt;
      &lt;%--↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ContextMenu↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑--%&gt;
  
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>First question is how to get ID of selected cell? I mentioned place where is the problem in my code.</p>
  
  <p>I have event handlers for edit.click() and delete.click() in code-behind. In edit.click() I'm binding a data source to a helpRow GridView.</p>
  
  <p>My second Question is how to show this HelpRow GridView right under the row that was clicked? I can't find the way how to set right position for this grid... I know that it should be absolute position and X and Y position...</p>
  
  <p>So the whole Idea:
  User right clicks on some cell. I need to show context menu ("Edit" and "Delete") and at this moment store rowID and cellID (rowid i got, but cellid is the problem...). When user clicks edit, I need to bind some data (it's stores in Session) based on rowid to helpRow Grid View. Then I need to show this helRow right under selected row (Position: absolute and ... HOW TO GET RIGHT POSITION???) and make selected cell in edit mode and set focus to this cell.</p>