62,046
社区成员
发帖
与我相关
我的任务
分享
<RowStyle BackColor="#e6e6fa" Height="22" ForeColor="Black" />
<AlternatingRowStyle BackColor="#f5f5dc" Height="22" ForeColor="Black" />
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//应该是在这里实现,还请大侠出手帮忙!预祝新年快乐 !!
}
}
protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onclick", "setBg(this);");
e.Row.Attributes.Add("onmouseover", "setOverBg(this);");
}
}
<script>
var lastItem;
var lastItemColor;
var lastSelectItem;
var lastSelectItemColr;
function setBg(obj)
{
if(lastSelectItem!=null){
lastSelectItem.style.backgroundColor=lastSelectItemColor;
}
lastSelectItem=obj;
lastSelectItemColor=lastItemColor;
obj.style.backgroundColor="#999999";
}
function setOverBg(obj)
{
if(lastItem!=null&&lastItem!=lastSelectItem){
lastItem.style.backgroundColor=lastItemColor;
}
lastItem=obj;
if(obj!=lastSelectItem){
lastItemColor=obj.style.backgroundColor;
obj.style.backgroundColor="#E7E7E7";
}
}</script>
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//onmouseover 鼠标悬停效果,变色
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff'");
//onmouseout 鼠标移除效果,恢复原来行的颜色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");
//单击后,让这行处于选中状态,变为红色
e.Row.Attributes.Add("onclick", "this.style.backgroundColor='#ff6633'");
//但是我想实现在没有单击其它行前,之前的那个选 中行,颜色要一直是红色的
//颜色不受 onmouseover 和 onmouseout 影响,直到有其它行被选 中,那时,这行
//才恢复原来颜色
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
for (int i = 0; i < GridView1.Rows.Count; i++)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='00BFFF'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
}
}
}
e.Row.Attributes.Add("onmouseover","currentcolor=this.style.backgroundColor;this.style.backgroundColor='#66FF33'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");