你可以轻松地做到:
<asp:Repeater ID="rptCityFriends" runat="server" OnItemDataBound="rptFriendsContainer_DataBound">
<ItemTemplate>
<asp:ImageButton ID="imgThumb" runat="server" PostBackUrl='<%# Eval("FBUsuarioID","~/Friends.aspx?friendID={0}") %>' ImageUrl='<%# Eval("FBAvatarUsuario") %>' CssClass="imgThumbs" />
</ItemTemplate>
</asp:Repeater>
但如果我想传递两个Querystrings?I.E:
<asp:Repeater ID="rptCityFriends" runat="server" OnItemDataBound="rptFriendsContainer_DataBound">
<ItemTemplate>
<asp:ImageButton ID="imgThumb" runat="server" PostBackUrl='<%# Eval("FBUsuarioID","FBNomeUsuario","~/Friends.aspx?friendID={0}&nUser={1}") %>' ImageUrl='<%# Eval("FBAvatarUsuario") %>' CssClass="imgThumbs" />
</ItemTemplate>
</asp:Repeater>
如何在“Eval DataBinding”中为URL设置两个或更多查询字符串?
答案 0 :(得分:8)
使用String.Format()
,即
<asp:Repeater ID="rptCityFriends" runat="server" OnItemDataBound="rptFriendsContainer_DataBound">
<ItemTemplate>
<asp:ImageButton ID="imgThumb" runat="server" PostBackUrl='<%# String.Format("~/Friends.aspx?friendID={0}&nUser={1}", Eval("FBUsuarioID"), Eval("FBNomeUsuario")) %>' ImageUrl='<%# Eval("FBAvatarUsuario") %>' CssClass="imgThumbs" />
</ItemTemplate>
</asp:Repeater>