2012-07-27 151 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