原文发布时间为:2009-04-21 —— 来源于本人的百度文章 [由搬家工具导入]
点击行,链接!!
可这样,在GridView的RowDataBound输入代码,假如id在第0列,且不是摸板列:
- C# code
- protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e){ if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("style", "cursor: hand;");//将光标设为手形 e.Row.Attributes.Add("onclick", "ItemOver(this," + e.Row.Cells[0].Text + ")"); }}
js代码:
- JScript code
- <script language="javascript" type="text/javascript"> if (!objbeforeItem) { var objbeforeItem=null; var objbeforeItembackgroundColor=null; } function ItemOver(obj,id) { if(objbeforeItem) { objbeforeItem.style.backgroundColor = objbeforeItembackgroundColor; } objbeforeItembackgroundColor = obj.style.backgroundColor; objbeforeItem = obj; obj.style.backgroundColor = "#FFFF00"; window.open("default1.aspx?id="+id); }</script>
时间: 2024-10-08 10:14:38