2012-07-27 153 views
3

的onmouseover手形图标我有一个GridView:没有显示

<asp:GridView ID="gvwProd" runat="server" CssClass="gridview" ShowHeaderWhenEmpty="true" 
             AllowPaging="true" BackColor="ButtonFace" OnRowDataBound="gvwProd_OnRowDataBound" 
             OnRowCreated="gvwProd_RowCreated" OnSorting="gvw_OnSorting" AllowSorting="true" 
             AutoGenerateColumns="false" ShowFooter="false"> 

我想设置一个手悬停图标上每行一个特定的细胞:

protected void gvwProd_OnRowDataBound(object sender, GridViewRowEventArgs e) 
{ 
    if (e.Row.RowType == DataControlRowType.DataRow) 
    { 
     e.Row.Cells[2].Attributes.Add("onmouseover", "document.body.style.cursor='hand'"); 
     e.Row.Cells[2].Attributes.Add("onmouseout", "document.body.style.cursor='auto'"); 
    } 
} 

的onmousover和onmouseout事件出现在标记中:

<td onmouseover="document.body.style.cursor=&#39;hand&#39;" onmouseout="document.body.style.cursor=&#39;auto&#39;" style="white-space:nowrap;">05-07-2012</td> 

但是,没有可见的手迹,也没有看到发生任何事情。我究竟做错了什么?使用IE 8

回答

4

第一:使用cursor: pointercursor: hand(如果你想,它在多个浏览器的工作原理)

二:不要使用document.body 的我会用this

e.Row.Cells[2].Attributes.Add("onmouseover", "this.style.cursor='pointer'"); 

自你想要光标onmouseover的单元格。

+0

工作完美! – Ted 2012-07-27 17:46:21