在ASP.NET中用GridView做好数据绑定后,如何给每一列的内容作超链接,
最好能打开一个新的页面显示全部内容,
还有一点就是怎么用脚本语言实现鼠标移动到这一行是颜色变化,
当然不一定是脚本实现,什么都可以实现就行啦,呵呵....谢谢啦
期待高手的指点
最好能打开一个新的页面显示全部内容,
还有一点就是怎么用脚本语言实现鼠标移动到这一行是颜色变化,
当然不一定是脚本实现,什么都可以实现就行啦,呵呵....谢谢啦
期待高手的指点
http://blog.csdn.net/oec2003/archive/2007/05/07/1599707.aspx
{
string Test=e.Row.Cells[0].ToString();
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff';");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor;");
}
}
直接添加GridView的RowDataBound消息加入代码
给gridview加模板列,模板列加HyperLink控见.2.鼠标移过变色:
在GridView的RowDataBound事件中输入以下代码:
e.Row.Attributes.Add "onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#ffffff'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff';");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor;");
}
}
<ItemTemplate>
<div style="border-bottom:1px #CCCCCC dashed;width:100%;margin-left:10px;height:18px;font-size:12px;padding-top:7px;font-family:宋体;color:#404040">
·<a href="NewsReleased/<%# Eval("name") %>"><%# Eval("Title") %></a>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("Time") %>'></asp:Label>
</div>
</ItemTemplate>
变色的代码:
<script language="VBScript">
sub hello
document.fgColor=int(256*256*256*rnd)
end sub
</script>
<HeaderStyle CssClass="tit_list_01" HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<a href=“XX连接地址”target=_blank ">
<%#DataBinder.Eval(Container.DataItem,"绑定字段名")%>
</a>
</ItemTemplate>
</asp:TemplateColumn>
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff';");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor;");
}
}
上面的不是说得很清楚吗?
#region[GV_Brand行加载事件]
//GV_Brand行加载事件
protected void GV_Brand_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//当鼠标停留时更改背景色
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#E6E6FA'");
//当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
//鼠标双击事件,跳转页面
e.Row.Attributes.Add("ondblclick", "self.location='a.aspx?id="
+ GV_Brand.DataKeys[e.Row.RowIndex].Value.ToString() + "'");
}
}
#endregion