您的位置:首页 > 其它

给gridview增加行链接,点击行任意位置进行跳转

2017-07-12 00:05 309 查看
原文发布时间为:2009-04-14 —— 来源于本人的百度文章 [由搬家工具导入]

可这样,在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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐