【问题标题】:ASP.Net - Gridview row selection and effectsASP.Net - Gridview 行选择和效果
【发布时间】:2010-06-15 17:56:33
【问题描述】:

我正在使用以下代码来尝试允许用户通过单击行上的任意位置(加上鼠标悬停和移出)效果来选择 gridview 行。该代码似乎没有应用于 rowdatabound,我无法闯入事件。 (是有线的)。

该控件位于用户控件中,该控件位于具有母版页的内容页面中。


    protected void gvOrderTypes_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        GridView gvOrdTypes = (GridView)sender;

        //check the item being bound is actually a DataRow, if it is,   
        //wire up the required html events and attach the relevant JavaScripts
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes["onmouseover"] = "javascript:setMouseOverColor(this);";
            e.Row.Attributes["onmouseout"] =  "javascript:setMouseOutColor(this);";
            e.Row.Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink(gvOrdTypes, "Select$" + e.Row.RowIndex);
        }
    }

【问题讨论】:

    标签: asp.net gridview


    【解决方案1】:

    从头开始。处理程序连接到数据绑定事件而不是行数据绑定。对不起大家。作为旁注,代码有效

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-03-28
      • 2012-11-28
      • 2010-11-23
      • 2010-11-10
      • 1970-01-01
      • 2014-02-28
      • 2019-08-27
      相关资源
      最近更新 更多