Gridview右键单击事件

Gridview右键单击事件

本文介绍了Gridview右键单击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我在gridview行鼠标上打开功能区菜单

但我不会在右键单击gridview行时打开它。

如何做到这一点....



我正在使用以下代码





Hi
I am open ribbon menu on gridview row mouse over
but I won't to open that on right click of gridview row .
how to do this....

I am using following code for this


private void SetGridRows(GridView gv)
      {
          int iRowCount = 0;
          foreach (GridViewRow gr in gv.Rows)
          {
              Label lblName = (Label)gr.FindControl("WorkID");
              string id = lblName.Text;
              string sClass = "ListNorRow";
              if (iRowCount == 1)
              {
                  sClass = "ListAltRow";
              }
              gr.Attributes.Add("onmouseout", "javascript:this.className='" + sClass + "'");
              gr.Attributes.Add("onmouseover", "ShowPopup('" + id + "');javasscript:this.className='ListSelRow';");
              gr.Attributes.Add("OnClick", "HideContent('SubMenu');");
              iRowCount = iRowCount == 0 ? 1 : 0;
          }
      }

推荐答案

Quote:

使用oncontextmenu事件。



这是一个例子:

Use the oncontextmenu event.

Here's an example:

<div oncontextmenu="javascript:alert('success!');return false;">
    Lorem Ipsum
</div>



不要忘记返回false,否则标准上下文m enu仍会弹出。


Don't forget to return false, otherwise the standard context menu will still pop up.



因此,您可以为每个<$ c $为此事件添加 SetGridRows 函数中的代码c> GridViewRow 正如您为 onmouseout onmouseover 所做的那样。


So, you can add the code in SetGridRows function for this event for each GridViewRow as you have done for onmouseout and onmouseover.


这篇关于Gridview右键单击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 05:15