asp.net GridView控件鼠標(biāo)移動(dòng)某行改變背景顏色(方法一)
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)過(guò)時(shí),行背景色變
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#00A9FF'");
//鼠標(biāo)移出時(shí),行背景色變
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");
}
}
}
<table align="center" bgcolor="#c0de98" border="0" cellpadding="0" cellspacing="1" width="99%">
<tr>
<th colspan="2">
GridView演示</th>
</tr>
<tr>
<td colspan="2" style="width: 100%;" >
<asp:GridView ID="GridView" runat="server" Width="100%" 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="更新時(shí)間" />
</Columns>
<RowStyle HorizontalAlign="Center" />
<PagerStyle HorizontalAlign="Right" />
</asp:GridView>
</td>
</tr>
</table>

- ASP.NET 2.0/3.5中直接操作Gridview控件插入新記錄
- asp.net GridView控件中模板列CheckBox全選、反選、取消
- asp.net GridView控件中實(shí)現(xiàn)全選的解決方案
- ASP.NET2.0中用Gridview控件操作數(shù)據(jù)的代碼
- ASP.NET GridView控件在列上格式化時(shí)間及DataFormatString使用
- asp.net的GridView控件使用方法大全
- asp.net中GridView控件遍歷的小例子
- Asp.net的GridView控件實(shí)現(xiàn)單元格可編輯方便用戶使用
- ASP.NET4 GridView的四種排序樣式詳解
- ASP.NET使用GridView導(dǎo)出Excel實(shí)現(xiàn)方法
- asp.net gridview分頁(yè):第一頁(yè) 下一頁(yè) 1 2 3 4 上一頁(yè) 最末頁(yè)
- ASP.NET中為GridView添加刪除提示框的方法
- asp.net中GridView數(shù)據(jù)鼠標(biāo)移入顯示提示信息
- 如何用jQuery實(shí)現(xiàn)ASP.NET GridView折疊伸展效果
- ASP.NET GridView中加入RadioButton不能單選的解決方案
- 靈活掌握asp.net中g(shù)ridview控件的多種使用方法(上)
- 靈活掌握asp.net中g(shù)ridview控件的多種使用方法(下)
相關(guān)文章
.net core下對(duì)于附件上傳下載的實(shí)現(xiàn)示例
本篇文章主要介紹了.net core下對(duì)于附件上傳下載的實(shí)現(xiàn)示例,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-03-03.net mvc頁(yè)面UI之Jquery博客日歷控件實(shí)現(xiàn)代碼
最近在做一個(gè)博客系統(tǒng),其他需要用到博客日歷控件,網(wǎng)上搜索了很多資料,其中大部分都是javascript的,經(jīng)過(guò)總結(jié)使用jquery實(shí)現(xiàn)了博客日歷效果。代碼如下2013-09-09asp.net?Core中同名服務(wù)注冊(cè)的實(shí)現(xiàn)代碼
Asp.Net?Core中自帶了容器,同時(shí)也可以使用AutoFac替換掉默認(rèn)的容器,以下為兩種方式同名服務(wù)的注冊(cè)實(shí)現(xiàn),對(duì)asp.net?Core服務(wù)注冊(cè)的實(shí)現(xiàn)代碼感興趣的朋友一起看看吧2022-03-03EasyUI Tree+Asp.net實(shí)現(xiàn)權(quán)限樹(shù)或目錄樹(shù)導(dǎo)航的簡(jiǎn)單實(shí)例
本篇文章主要是對(duì)EasyUI Tree+Asp.net實(shí)現(xiàn)權(quán)限樹(shù)或目錄樹(shù)導(dǎo)航的簡(jiǎn)單實(shí)例進(jìn)行了介紹,需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助2014-02-02運(yùn)用.net core中實(shí)例講解RabbitMQ高可用集群構(gòu)建
這篇文章主要介紹了運(yùn)用.net core中實(shí)例講解RabbitMQ高可用集群構(gòu)建,文中相關(guān)示例代碼講解的非常清晰,感興趣的小伙伴可以參考一下這篇文章,相信可以幫助到你2021-09-09淺談Asp.Net母版頁(yè)和內(nèi)容頁(yè)運(yùn)行機(jī)制
這篇文章主要介紹了淺談Asp.Net母版頁(yè)和內(nèi)容頁(yè)運(yùn)行機(jī)制,詳細(xì)的介紹了母版頁(yè)和內(nèi)容頁(yè)的運(yùn)行過(guò)程步驟,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-11-11更方便快捷的外部操作數(shù)據(jù)庫(kù)的方法(另類玩法)
數(shù)據(jù)庫(kù)操作方法很多,各種各樣但是外部操作數(shù)據(jù)庫(kù)的方法就會(huì)顯得格外陌生了,感興趣的朋友可以詳細(xì)了解下本文,或許對(duì)你學(xué)習(xí)ado.net有所幫助2013-02-02c#中兩種不同的存儲(chǔ)過(guò)程調(diào)用與比較
存儲(chǔ)過(guò)程的調(diào)用在B/S系統(tǒng)中用的很多。傳統(tǒng)的調(diào)用方法不僅速度慢,而且代碼會(huì)隨著存儲(chǔ)過(guò)程的增多不斷膨脹,難以維護(hù)。新的方法在一定程度上解決了這些問(wèn)題2012-12-12