Gridview中实现行变色--在线等 各位大侠:我在使用gridview时,在里面有一个linkbutton字段,我希望当点击这个字段的某一行时,这一行的颜色变化,一直到我点击下一行时,这行颜色恢复,而下一行颜色变化!谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //****在后台RowDataBound事件进行处理 foreach (GridViewRow gdVRow in GView.Rows) { gdVRow.Attributes.Add("onclick", "this.className='onclickbackgroundcolor'"); //****获取处理按钮 LKBtnDelete = (LinkButton)gdVRow.FindControl("LKBtnDelete"); //****邦定javascript LKBtnDelete.Attributes.Add("onclick","javascript:if(confirm('请确认是否删除记录为[" + e.Row.Cells[2].Text + "]记录!')==false) return false;"); }//****这里高用一个CSS函数 <asp:gridview id="GridView1" autogeneratecolumns="true" autogenerateselectbutton="true" allowpaging="true" selectedindex="0" runat="server"> <selectedrowstyle backcolor="LightCyan" forecolor="DarkBlue" font-bold="true"/> </asp:gridview>在<asp:gridview>与</asp:gridview>之间加 <selectedrowstyle backcolor="LightCyan" forecolor="DarkBlue" font-bold="true"/> seaonce(雨花中的小皮鞋) ,你说的方法,要增加一行选择,而且,只有选他才能实现功能.zhangxiaopin(zxp) ,你说的,我还没有看懂,能不能在写清楚些,谢谢 foreach (GridViewRow gvRow in gridview1.Rows) { gdVRow.Attributes.Add("onmouseover", "this.backgroundColor='#ffffff'"); gdVRow.Attributes.Add("onmouseout", "this.backgroundColor='#ffffff'"); } 在GridView中添加一选择列.将GridView中选择好自动套用的格式.也就是外面.当你点选择选项的时候行就变颜色突出了 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e){ if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='ivory'"); e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='white'"); }} http://www.cnblogs.com/weekzero/archive/2006/05/05/392188.html参考 protected void gvLawRule_RowDataBound(object sender, GridViewRowEventArgs e) { try { if (e.Row.RowIndex > -1) { e.Row.Cells[1].Text = "<a target='_blank' href='LawRuleBrowse.aspx?LawruleID=" + Tool.UtilTool.ToSafeInt32(gvLawRule.DataKeys[e.Row.RowIndex].Value) + "'>" + e.Row.Cells[1].Text + "</a>";//链接转到别的页上 if (e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.RowType != DataControlRowType.Header) { e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#cccccc'");///行交替变色 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#ffffff'"); } } } } catch (Exception ex) { this.lblMessage.Text = ex.Message; } } 大家说的方法,好象都是鼠标经过的时候,行的颜色发生变化,我想做的是:只有点击LinkButton的字段,行就变颜色,一直到点击另一行,这行恢复原来的颜色,如果不点击的话,这行的 颜色一直不变 如何获取IP? 未结束的字符串常量 mvc + linq 的问题非常简单! AJAX无刷新错误调试的问题 一个穷举算法【看看.NET程序员的算法水准】 美女问我问题,大家赶快来帮忙,正则表达式 请教,抓取露天价钱号分析〜WebBrowser的~~ 求一句SQL语言,返回符合条件的记录的总数目 如何将动态网站的内容自动转换成静态页面 谢谢大家的支持!!!在用asp.net做留言本的程序中,大家在显示留言内容的时候(当然要分页),一般都使用什么控件呀? GridView的FootRow做数据输入栏,但是电击按钮 页面出错 关于在虚拟主机上使用IE web控件的问题??
{
gdVRow.Attributes.Add("onclick", "this.className='onclickbackgroundcolor'"); //****获取处理按钮
LKBtnDelete = (LinkButton)gdVRow.FindControl("LKBtnDelete");
//****邦定javascript
LKBtnDelete.Attributes.Add("onclick","javascript:if(confirm('请确认是否删除记录为[" + e.Row.Cells[2].Text + "]记录!')==false) return false;");
}//****这里高用一个CSS函数
<asp:gridview id="GridView1"
autogeneratecolumns="true"
autogenerateselectbutton="true"
allowpaging="true"
selectedindex="0" runat="server">
<selectedrowstyle backcolor="LightCyan"
forecolor="DarkBlue"
font-bold="true"/>
</asp:gridview>
在<asp:gridview>与</asp:gridview>之间加 <selectedrowstyle backcolor="LightCyan"
forecolor="DarkBlue"
font-bold="true"/>
zhangxiaopin(zxp) ,你说的,我还没有看懂,能不能在写清楚些,
谢谢
{
gdVRow.Attributes.Add("onmouseover", "this.backgroundColor='#ffffff'");
gdVRow.Attributes.Add("onmouseout", "this.backgroundColor='#ffffff'");
}
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='ivory'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='white'"); }
}
{
try
{
if (e.Row.RowIndex > -1)
{
e.Row.Cells[1].Text = "<a target='_blank' href='LawRuleBrowse.aspx?LawruleID=" + Tool.UtilTool.ToSafeInt32(gvLawRule.DataKeys[e.Row.RowIndex].Value) + "'>" + e.Row.Cells[1].Text + "</a>";//链接转到别的页上 if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowType != DataControlRowType.Header)
{
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#cccccc'");///行交替变色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#ffffff'");
}
}
}
}
catch (Exception ex)
{
this.lblMessage.Text = ex.Message;
}
}