代码如下:
<%@ Page language="c#" Codebehind="DataGridStudy.aspx.cs" AutoEventWireup="false" Inherits="CheckBoxStudy.DataGridStudy" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>DataGridStudy</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<script language="C#" runat="server">
protected void dgEnginePrice_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType!=ListItemType.Header)
{
e.Item.Attributes.Add("onmouseover","currentcolor=this.style.backgroundColor;this.style.backgroundColor='#C1D2EE'");
//添加自定义属性,当鼠标移走时还原该行的背景色
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=currentcolor");
}
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:DataGrid id="dgEnginePrice" style="Z-INDEX: 101; LEFT: 128px; POSITION: absolute; TOP: 95px"
OnItemDataBound="dgEnginePrice_ItemDataBound" runat="server" Width="439px" ShowFooter="True"
AllowPaging="True" BackColor="LightGoldenrodYellow">
<SelectedItemStyle ForeColor="GhostWhite" BackColor="DarkSlateBlue"></SelectedItemStyle>
<HeaderStyle Font-Bold="True" BackColor="Tan"></HeaderStyle>
<AlternatingItemStyle BackColor="PaleGoldenrod"></AlternatingItemStyle>
<FooterStyle BackColor="Tan"></FooterStyle>
<Columns>
<asp:ButtonColumn Text="选择" CommandName="Select"></asp:ButtonColumn>
</Columns>
<PagerStyle NextPageText="下一页" PrevPageText="上一页" HorizontalAlign="Right" ForeColor="DarkSlateBlue"
BackColor="PaleGoldenrod"></PagerStyle>
</asp:DataGrid></form>
</body>
</HTML>
问题1、如何当鼠标经过一行时,鼠标图标变成手指状,且在点击时,可以选择这一行这选定行
问题2、请教做工具栏(首页,上一页,转到X页,下一页,尾页,当前面/总页数)的代码

解决方案 »

  1.   

    e.Item.Attributes.Add("onmouseover","currentcolor=this.style.backgroundColor;this.style.backgroundColor='#C1D2EE';cursor:hand");
      

  2.   

    to: foxconn_nich(—— http://www.joke-online.net ——) 
    有錯誤:
    錯誤:'hand'未被定義
      

  3.   

    /// <summary>
    /// 表格随鼠标移动行变色
    /// </summary>
    /// <param name="e"></param>
    public  void AddColorItemOfMouseMove(ref DataGridItemEventArgs e)
    {
    if(e.Item.ItemIndex!=-1) 
    {
    e.Item.Attributes.Add("onmouseover","this.setAttribute('BKC',this.style.backgroundColor);this.style.cursor='hand',this.style.backgroundColor='LIGHTCYAN'");
    e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=this.getAttribute('BKC');");
    }
    }
      

  4.   

    表格点击改变颜色
    if (e.Item.ItemType == ListItemType.Item ||e.Item.ItemType == ListItemType.AlternatingItem)
    {
      e.Item.Attributes.Add("onclick","this.style.backgroundColor='#99cc00';this.style.color='buttontext';this.style.cursor='default';");
    }
      

  5.   

    http://community.csdn.net/Expert/topic/4408/4408414.xml?temp=.6485559
      

  6.   

    随便问一下,学习中,
    用过codebehind之后,还可以这样吗?
    <script language="C#" runat="server">
    protected void dgEnginePrice_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    if(e.Item.ItemType!=ListItemType.Header)
    {
    e.Item.Attributes.Add("onmouseover","currentcolor=this.style.backgroundColor;this.style.backgroundColor='#C1D2EE'");
    //添加自定义属性,当鼠标移走时还原该行的背景色
    e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=currentcolor");
    }
    }
    </script>
      

  7.   

    http://singlepine.cnblogs.com/articles/266538.htmlhttp://singlepine.cnblogs.com/articles/281425.html