各位大侠:
我在使用gridview时,在里面有一个linkbutton字段,我希望当点击这个字段的某一行时,这一行的颜色变化,一直到我点击下一行时,这行颜色恢复,而下一行颜色变化!
谢谢!

解决方案 »

  1.   

    //****在后台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函数
      

  2.   


             <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"/>
      

  3.   

    seaonce(雨花中的小皮鞋) ,你说的方法,要增加一行选择,而且,只有选他才能实现功能.
    zhangxiaopin(zxp) ,你说的,我还没有看懂,能不能在写清楚些,
    谢谢
      

  4.   

    foreach (GridViewRow gvRow in gridview1.Rows)
            {
             
       gdVRow.Attributes.Add("onmouseover", "this.backgroundColor='#ffffff'");
       gdVRow.Attributes.Add("onmouseout", "this.backgroundColor='#ffffff'");
            }
      

  5.   

    在GridView中添加一选择列.将GridView中选择好自动套用的格式.也就是外面.当你点选择选项的时候行就变颜色突出了
      

  6.   

    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'");        }
    }
      

  7.   

    http://www.cnblogs.com/weekzero/archive/2006/05/05/392188.html参考
      

  8.   

    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;
            }
        }
      

  9.   

    大家说的方法,好象都是鼠标经过的时候,行的颜色发生变化,我想做的是:只有点击LinkButton的字段,行就变颜色,一直到点击另一行,这行恢复原来的颜色,如果不点击的话,这行的 颜色一直不变