ASP.NET Eval DataBinding C#
You can do easily:
<asp:Repeater ID="rptCityFriends" runat="server" OnItemDataBound="开发者_如何学PythonrptFriendsContainer_DataBound">
<ItemTemplate>
<asp:ImageButton ID="imgThumb" runat="server" PostBackUrl='<%# Eval("FBUsuarioID","~/Friends.aspx?friendID={0}") %>' ImageUrl='<%# Eval("FBAvatarUsuario") %>' CssClass="imgThumbs" />
</ItemTemplate>
</asp:Repeater>
But if i want to pass two 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>
How can I set two or more querystrings to an URL in "Eval DataBinding"?
Use String.Format()
, i.e.
<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>
精彩评论