gridview 行样式 在gridview里面怎么达到一个效果就是鼠标经过行的时候,行的颜色会变,鼠标离开,颜色恢复默认,不需要鼠标点击。是加鼠标事件吗?在asp里面,鼠标事件加在<tr>里面在.net里面应该加在哪里?请大家指点,谢谢。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个网上一堆堆 lz 给分吧。 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='LightSkyBlue',this.style.fontWeight='';"); e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';"); } } protected void GridView_RowDataBound(object sender,GridViewRowEventArgs e){ if(e.Row.RowType == DataContrelRowType.DataRow) { e.Attributes.Add("onmouseover","this.style.backgroundColor='#EEEEEE';"); e.Attributes.Add("onmouseout","this.style.backgroundColor='#FFFFFF';"); }} http://tech.163.com/06/1010/11/2T2Q12E00009215D.html这个视频教程上说的很详细.来分吧. protected void GridView_RowDataBound(object sender,GridViewRowEventArgs e) { if(e.Row.RowType == DataContrelRowType.DataRow) { e.Row.Attributes.Add("onmouseover","this.style.backgroundColor='#EEEEEE';"); e.Row.Attributes.Add("onmouseout","this.style.backgroundColor='#FFFFFF';"); } }用这个.. 5楼的和2楼的一样 if(e.Row.RowType == DataContrelRowType.DataRow) 提示 当前上下文中不存在名称“DataContrelRowType” DataContrelRowType在System.Web.UI.WebControls 下 谢谢大家,效果已经出来了还有最后一点,鼠标移走的时候,行颜色能不能不指定,而是回复默认。如果必须指定回复成某个颜色的话,gridview 有个交替行,两个行的默认颜色不一样,protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#afd6f5';"); e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#F1F9FE';"); } }应该怎么修改? 当然可以,把e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#F1F9FE';")去掉. protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#afd6f5';"); e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor;"); } } 得到我要的效果了,谢谢大家了。 连不上远程数据库了! 网站后台编写 跨域存储用户信息 xml+xsl+html的问题 十万火急,客户正在开骂, sqlserver2000升级不了sp4 Hjin588来!!!给100分给你,帮我个忙! 在asp.net(c#)中怎样使数据库连接超过一定时间(比如说3秒)若是连不上就停止连接,继续执行下面的代码? 一个DataGrid的问题 asp.net mvc 如何使用codefirst 迁移数据库? 跪求解决方法。 如果设置图片访问权限? gridview 模板列问题 GridView导入EXCEL的问题。。。。。在线等!!!!
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='LightSkyBlue',this.style.fontWeight='';");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';");
} }
{
if(e.Row.RowType == DataContrelRowType.DataRow)
{
e.Attributes.Add("onmouseover","this.style.backgroundColor='#EEEEEE';");
e.Attributes.Add("onmouseout","this.style.backgroundColor='#FFFFFF';");
}
}
这个视频教程上说的很详细.来分吧.
{
if(e.Row.RowType == DataContrelRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover","this.style.backgroundColor='#EEEEEE';");
e.Row.Attributes.Add("onmouseout","this.style.backgroundColor='#FFFFFF';");
}
}
用这个..
if(e.Row.RowType == DataContrelRowType.DataRow)
提示 当前上下文中不存在名称“DataContrelRowType”
还有最后一点,鼠标移走的时候,行颜色能不能不指定,而是回复默认。如果必须指定回复成某个颜色的话,
gridview 有个交替行,两个行的默认颜色不一样,protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#afd6f5';");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#F1F9FE';");
}
}应该怎么修改?
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#afd6f5';");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor;");
}
} 得到我要的效果了,谢谢大家了。