怎么实现gridview单击某一行链接到相关网页
如何实现gridview单击某一行链接到相关网页
如果
注意 是 单击行 而不是 单击行里的 某项
另外 要求是 链接 <a href 地址>
马上给分
------解决方案--------------------
如果
注意 是 单击行 而不是 单击行里的 某项
另外 要求是 链接 <a href 地址>
马上给分
------解决方案--------------------
- C# code
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { e.Row.Attributes["onclick"] = String.Format("JavaScript:window.open({0})", "http://www.****.net"); }
------解决方案--------------------
同意楼上。
- C# code
e.Row.Attributes["onclick"] = string.Format("window.open('{0}');", "http://www.****.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属性。
}
------解决方案--------------------
------解决方案--------------------
- C# code
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { e.Row.Attributes["onclick"] = String.Format("JavaScript:location.href='http://www.****.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 + "'");
}
}