DataList 添加超链接项


<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" Height="392px"
            Style="z-index: 24; left: 377px; position: absolute; top: 48px" Width="332px">
            <ItemTemplate>               
               <asp:Label ID="articlenameLabel" runat="server" Text='<%# Eval("articlename") %>'>
                </asp:Label>     
                <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%#Eval("articlename","readarticle.aspx?articlename={0}")%>' >详细</asp:HyperLink>
                     
            </ItemTemplate>
        </asp:DataList>


<asp:DataList ID="DataList2" runat="server" Style="z-index: 101; left: 50px; position: absolute;
            top: 58px" Height="291px" Width="181px" DataSourceID="SqlDataSource1 ">
            <ItemTemplate>  
            <a href='readarticle.aspx?id=<%# DataBinder.Eval(Container.DataItem,"ID") %>& name=<%#DataBinder.Eval(Container.DataItem,"articlename")%>'   target="_blank">  
            <%#DataBinder.Eval(Container.DataItem, "articlename")%>   (先绑定数据库)
            </a>  
</ItemTemplate>
        </asp:DataList>


<asp:HyperLink ID="HyperLink1" runat ="server" Text = <%# Eval("iid")%> NavigateUrl ="http://www.sina.com.cn" ></asp:HyperLink>


/// <summary>
/// 链接到浏览页面

/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void gvConmanShip_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowIndex > -1)
{
e.Row.Cells[1].Text = "<img src='../../Images/biaoqian.gif'><a target='_blank' href='BreakfaithBrowse.aspx?BreakfaithID=" + Tool.UtilTool.ToSafeInt32(gvBreakfaith.DataKeys[e.Row.RowIndex].Value) + "'>" + e.Row.Cells[1].Text + "</a>";
}
}
catch (Exception ex)
{
this.lblMessage.Text = ex.Message;
}
}


HTML 端代码:<%#show(DataBinder.Eval(Container.DataItem, OrderID
))%>
在后台代码是一个show() 的方法:
public string show (object orderID)
{
   return
"<a href=WebForm2.aspx?id="+orderID+" target='_blank'>"+orderID+" </a>";
}

展开阅读全文

没有更多推荐了,返回首页