如何实现gridview单击某一行链接到相关网页 如果注意 是 单击行 而不是 单击行里的 某项另外 要求是 链接 <a href 地址>马上给分 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { e.Row.Attributes["onclick"] = String.Format("JavaScript:window.open({0})", "http://www.csdn.net"); } 不知道你为什么非要<a href>? 单击行也只能是给这个row加上事件然后javascript去做.这个行本来不可能被<a >...</a>包含起来. 说白了给row加事件最终也只是给输入的table 的 row加上事件. 了解原理比实现功能更能提高自己. 同意楼上。 e.Row.Attributes["onclick"] = string.Format("window.open('{0}');", "http://www.csdn.net"); e.Row.Attributes["onmouseover"] = "this.style.backgroundColor='Maroon';this.style.color='White';this.style.cursor='hand';"; e.Row.Attributes["onmouseout"] = "this.style.backgroundColor='White';this.style.color='Black';" 另外最好是在if(e.Row.RowType==DataControlRowType.DataRow){ //在这里为行添加css属性。 } 只能是 ON CLICK 吗 那就是 不可能 链接了 要求是 使用 的最终效果是<a href ......>因为用的是 GreyBox 这个东西 好象一般是用 Href来触发不知道能不能实现 或是 通过别的办理, 触发 GreyBox 知道1楼的意思问题是 要用到 GreyBox 你要以在javascript里面写一个打开某一链接的函数,那样子可以用<a>...</a>包含,但是不支持这么做 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { e.Row.Attributes["onclick"] = String.Format("JavaScript:location.href='http://www.csdn.net'); } <asp:HyperLinkField DataNavigateUrlFields="detaineeId" DataNavigateUrlFormatString="../InAndOutCalaboose/InCalabooseShow.aspx?Id={0}" Text="查 看"/>加这句在gridview里面,哥子,思想太僵化了是卜行滴~~~,那个路径自己改哈要不就得这样,好像也可以protected void gdvComplice_RowDataBound(object sender, GridViewRowEventArgs e) { //如果是绑定数据行 if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("ondblclick", "window.location.href='InCalaboose.aspx?Id=" + this.gridInCalaBooseList.DataKeys[e.Row.RowIndex].Value + "'"); } } 我要的链接是<a rel="gb_page_center[650,550]" title="公告通知" href="./WebForm/aaa.aspx?id=3635">那要 怎么办呢 点击button按钮弹出contextmenustrip菜单 数组元素比较问题?? PDF中XObject的数据解压缩后应该如何处理? pop3和smtp相关书籍 函数调用的问题 同一个treeview中节点的拖放? 服务端与客户通讯组件 这样也执行,奇怪阿 一个要用C#写的求出圆的面积难题 给asp:Button加上背景 日期转换 flash调用asp.net没读到数据
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Attributes["onclick"] = String.Format("JavaScript:window.open({0})", "http://www.csdn.net");
} 不知道你为什么非要<a href>? 单击行也只能是给这个row加上事件然后javascript去做.这个行本来不可能被<a >...</a>包含起来. 说白了给row加事件最终也只是给输入的table 的 row加上事件. 了解原理比实现功能更能提高自己.
e.Row.Attributes["onmouseover"] = "this.style.backgroundColor='Maroon';this.style.color='White';this.style.cursor='hand';";
e.Row.Attributes["onmouseout"] = "this.style.backgroundColor='White';this.style.color='Black';"
if(e.Row.RowType==DataControlRowType.DataRow)
{
//在这里为行添加css属性。
}
<a href ......>因为用的是 GreyBox 这个东西 好象一般是用 Href来触发
不知道能不能实现 或是 通过别的办理, 触发 GreyBox
你要以在javascript里面写一个打开某一链接的函数,那样子可以用<a>...</a>包含,但是不支持这么做
{
e.Row.Attributes["onclick"] = String.Format("JavaScript:location.href='http://www.csdn.net');
}
Text="查 看"/>加这句在gridview里面,哥子,思想太僵化了是卜行滴~~~,那个路径自己改哈要不就得这样,好像也可以
protected void gdvComplice_RowDataBound(object sender, GridViewRowEventArgs e)
{
//如果是绑定数据行
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("ondblclick", "window.location.href='InCalaboose.aspx?Id=" + this.gridInCalaBooseList.DataKeys[e.Row.RowIndex].Value + "'");
}
}