日期:2014-05-18 浏览次数:21188 次
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { //取主键的时候前面要加个判断,因为开始的时候是bof,不是从0开始的. //string aa = GridView1.DataKeys[e.Row.RowIndex].Value.ToString(); e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#9CCBF7';this.style.cursor='hand'"); e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c"); //注意格式,是单引号加双引号,否则会提示“常量中有换行符” //这地方注意传递主键的时候的方式 e.Row.Attributes.Add("ondblclick", "returnSelect('" + GridView1.DataKeys[e.Row.RowIndex].Value.ToString() + "','" + e.Row.Cells[1].Text.ToString() + "','" + e.Row.Cells[2].Text.ToString() + "','" + e.Row.Cells[3].Text.ToString() + "','" + e.Row.Cells[4].Text.ToString() + "','" + e.Row.Cells[5].Text.ToString() + "','" + e.Row.Cells[6].Text.ToString() + "');"); } }