3

私はグリッドビューを持っています:

    <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>

ただし、手の痕跡はなく、何も起きていないようです。私は何が間違っているのですか?IE8の使用

4

1 に答える 1

4

最初に:使用しcursor: pointerないでくださいcursor: hand(複数のブラウザーで機能させたい場合)

2番目:使用する代わりにdocument.body 私は使用しますthis

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

セルの上にカーソルを置く必要があるためです。

于 2012-07-27T17:38:39.177 に答える