开发者

Can I databind to an asp.net Image control?

I have a listview that is setup like so:

<asp:ListView ID="lv_First" runat="server">
    <LayoutTemplate>
            <div id="first" class="left slider slideAction">
                <div id="itemPlaceHolder" runat="server" />
            </div>
    </LayoutTemplate>
    <ItemTemplate>
        <asp:Image ID="img_Icon" runat="server" ImageUrl="<%# Eval("IconUrl") %>" Visible="false" /> <a id="<%# Eval("ParentId") %>-<%# Eval("ID") %>" title="<%# Eval("HelpText") %>"><%# Eval("Title") %></a>
    </ItemTemplate>
</asp:ListView>

When I have the <asp:Image ID="img_Icon" runat="server" ImageUrl="<%# Eval("IconUrl") %>" Visible="false" /> portion in there it errors out with:

The server tag is not well formed.

If I change it to:开发者_StackOverflow中文版

<asp:Image ID="img_Icon" runat="server" ImageUrl="http://test.com/test.png" Visible="false" /> It renders fine. What would cause this to happen?


In ASP.NET controls the Eval statement go in between single quotes no double quotes:

<asp:Image ID="img_Icon" runat="server" ImageUrl='<%# Eval("IconUrl") %>' Visible="false" />
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜