国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

asp.net GridView控件鼠標(biāo)移動某行改變背景顏色(方法一)

2024-07-10 13:18:34
字體:
供稿:網(wǎng)友

復(fù)制代碼 代碼如下:


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Demo19 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack == false)
{
BindData();
}
}

public void BindData()
{
string strSql = "select UserID,C_Name,E_Name,UpdataDate,QQ from Demo_User ";
DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.CONN_STRING, CommandType.Text, strSql, null).Tables[0];

GridView.DataSource = dt;
GridView.DataKeyNames = new string[] { "UserID" };//主鍵
GridView.DataBind();
}

protected void GridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView.PageIndex = e.NewPageIndex;
BindData();
}

protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//鼠標(biāo)經(jīng)過時,行背景色變
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#00A9FF'");
//鼠標(biāo)移出時,行背景色變
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");
}
}
}

<table bgcolor="#c0de98" cellpadding="0" cellspacing="1">
<tr>
<th colspan="2">
GridView演示</th>
</tr>
<tr>
<td colspan="2" >
<asp:GridView runat="server" AutoGenerateColumns="False" AllowPaging="True" OnPageIndexChanging="GridView_PageIndexChanging" PageSize="12" OnRowDataBound="GridView_RowDataBound" >
<Columns>
<asp:BoundField DataField="UserID" HeaderText="UserID" />
<asp:BoundField DataField="C_Name" HeaderText="中文名字" />
<asp:BoundField DataField="E_Name" HeaderText="英文名字" />
<asp:BoundField DataField="QQ" HeaderText="QQ" />
<asp:BoundField DataField="UpdataDate" HeaderText="更新時間" />
</Columns>
<RowStyle HorizontalAlign="Center" />
<PagerStyle HorizontalAlign="Right" />
</asp:GridView>
</td>
</tr>
</table>


asp.net GridView控件鼠標(biāo)移動某行改變背景顏色(方法一)

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 息烽县| 调兵山市| 北川| 通州市| 香港 | 铜山县| 措美县| 桑植县| 宣威市| 中牟县| 大竹县| 昌图县| 淳化县| 弥勒县| 金乡县| 吴江市| 图片| 贵德县| 彝良县| 琼海市| 博白县| 稻城县| 册亨县| 高安市| 英吉沙县| 资兴市| 恭城| 吉安县| 北海市| 台湾省| 西藏| 高碑店市| 珲春市| 富锦市| 潜山县| 香河县| 惠安县| 清原| 山东省| 荔浦县| 南漳县|