如题,我把一些网址显示在datagridview的一个列里,能不能实现在datagridview上直接点击某条网址直接就转到对应的网页上去?

解决方案 »

  1.   

    可以的.下面是一个简单例子.你可以改改.<ItemTemplate>
       <asp:linkbutton ID="Label1" runat="server" Text='<%# Bind("cardvaliddate") %>' ForeColor="#00C0C0" OnClientClick=<%# "parent.location.href='UpdateCardvalidDate.aspx?CardNo=" + Eval("PeoCurrCardNo") + "'" %>>
       </asp:linkbutton>
    </ItemTemplate>
      

  2.   

    可以啊
    添加列的时候,把列设成DataGridViewLinkColumn类型就可以了
      

  3.   

    办法一:假如你的第二列为网址内容,在gridview的RowDataBound里这么写就可以了
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
                e.Row.Cells[1].Text = "<a href='http://" + e.Row.Cells[1].Text + "' target='_blank'>" + e.Row.Cells[1].Text + "</a>";
    }