I use ListView in asp.net. I get data from provider table. According providerId image is stored in same folder(like 1.jpg,2.jpg).
I want to display image according to providerID.
But Image is not showing. but when i use simple html img control then image is showing.
What should i do for show image in ImageButton.
<asp:ListView DataSourceID="ObjectDataSource1" ItemPlaceholderID="dd" ID="ddlprovider"
runat="server">
<LayoutTemplate>
<ul>
<asp:PlaceHolder ID="dd" runat="server"/>
</ul>
</LayoutTemplate>
<ItemTemplate>
<asp:ImageButton runat="server" ImageUrl='<%#Eval("ProviderID") %>.jpg' ID="imgButton" />//Not work
<asp:LinkButton runat="server" CommandArgument='<%#Eval("ProviderID") %>'/>
</ItemTemplate>
</asp:ListView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
DeleteMethod="Delete" InsertMethod="Insert"
OldValuesParameterFormatString="original_{0}" SelectMethod="FetchAll"
TypeName="mogile.MidTier.DAL.ProviderController" UpdateMethod="Update">
</asp:ObjectDataSource>
You shouldn’t put code breaks in an attribute with a string at the end like that.
Try changing the line of code to:
EDIT:
If you wish to display a default image if this one doesn’t exist you’ll need to modify the code to: