开发者

ASP.NET Eval DataBinding C#

开发者 https://www.devze.com 2023-01-30 03:09 出处:网络
You can do easily: <asp:Repeater ID=\"rptCityFriends\" runat=\"server\" OnItemDataBound=\"开发者_如何学PythonrptFriendsContainer_DataBound\">

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

精彩评论

暂无评论...
验证码 换一张
取 消