致力于ASP.net企业级应用开发
找个地方,放些常用的技巧,呵呵,纯粹个人喜好。:)
  
  protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string s = "window.opener.document.getElementById('ctl00_MainContent_TextBox1').value='" + e.Row.Cells[0].Text + "';";
            string s1 = "window.opener.document.getElementById('ctl00_MainContent_TextBox2').value='" + e.Row.Cells[1].Text + "'; window.close();";
            e.Row.Attributes.Add("ondblclick", s+s1);//双击选择
            //当鼠标移到的时候设置该行颜色为"", 并保存原来的背景颜色
            e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#C0C0FF';this.style.cursor='hand';");
            //当鼠标移走时还原该行的背景色
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");
        }
    }

注意,先要判断是否数据行,再进行string的赋值,否则会出现指定的参数已超出有效值的范围 的错误提示。
posted on 2008-01-31 19:10  真实如我  阅读(456)  评论(0编辑  收藏  举报