代码如下:
<%@ 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页,下一页,尾页,当前面/总页数)的代码
<%@ 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页,下一页,尾页,当前面/总页数)的代码
解决方案 »
- 网页直接显示Excel
- asp.net中radiobuttonlist控件怎么只能选择指定的一个呢?
- 关于cookie的问题请指教
- (补充)查询
- iis 集成windows身份验证,也勾选了允许匿名访问,为什么登录进去的时候还是会弹出windows登录框?
- asp.net程序超出oracle数据库最大连接数,问题在哪?
- 江苏无锡(0510)的.net高手们来这里签名啊,打家认识一下
- 怎样让ASP.NET支持Access数据库中的中文表名?
- ASC函数C#怎么实现?
- 诚征:怎样扩大自己的社交范围???(想找个女朋友,多接触些人)保证给分!!!
- 如何在ASP.NET中直接把EXCEL另存成HTML啊
- 高分求博客换肤程序,或给个思路(Asp.net C#)
有錯誤:
錯誤:'hand'未被定義
/// 表格随鼠标移动行变色
/// </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');");
}
}
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';");
}
用过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>