在ASP.NET中用GridView做好数据绑定后,如何给每一列的内容作超链接,
最好能打开一个新的页面显示全部内容,
还有一点就是怎么用脚本语言实现鼠标移动到这一行是颜色变化,
当然不一定是脚本实现,什么都可以实现就行啦,呵呵....谢谢啦
期待高手的指点

解决方案 »

  1.   

    给gridview加模板列 模板列中加a标签就可以了鼠标变色 看这里
    http://blog.csdn.net/oec2003/archive/2007/05/07/1599707.aspx
      

  2.   

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
            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消息加入代码
      

  3.   

    1.超链接
    给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");
      

  4.   


    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;");
            }
        }
      

  5.   


    <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>
      

  6.   

    <asp:TemplateColumn HeaderText="XX名称">
    <HeaderStyle CssClass="tit_list_01" HorizontalAlign="center"></HeaderStyle>
    <ItemTemplate>
    <a  href=“XX连接地址”target=_blank ">
                    <%#DataBinder.Eval(Container.DataItem,"绑定字段名")%>
                </a>
    </ItemTemplate>
    </asp:TemplateColumn>
      

  7.   

    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;");
            }
        }
      

  8.   

    gridview中不就有超连接列吗??在里内加上去不就行了。。
    上面的不是说得很清楚吗?
      

  9.   


    #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