AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
 how to bind image in listview
Posted by arun kumar on  6/4/2010 6:34:19 AM Category: ADO.NET
Add to my favorites
Email to friend
If we are uploading an image in image folder(in solution explorer) using browse control and saving its path in database then how can we bind this image in listview using same image path and its image id.

Post Your Reply Post New Question

 Viewer's Reply
Binding Image in Asp.Net ListView control
Answered By Moderator1 on 6/9/2010 10:03:28 AM
Hi,

Use the below code:

<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1"
DataKeyNames="ImageID" EnableTheming="False">
<ItemTemplate>
<tr style="">
<td>
<asp:Label ID="ImageIDLabel" runat="server" Text='<%# Eval("ImageID") %>' />
</td>
<td>
<asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("ImagePath") %>' />
</td>
</tr>
</ItemTemplate>

<EmptyDataTemplate>
<table style="" runat="server">
<tr>
<td>
No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>

<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table ID="itemPlaceholderContainer" runat="server" border="0" style="">
<tr runat="server" style="">
<th runat="server">
ImageID</th>
<th runat="server">
ImagePath</th>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server" style="">
</td>
</tr>
</table>
</LayoutTemplate>

</asp:ListView>


<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:TestConnectionString %>"
SelectCommand="SELECT * FROM [TestImages]"></asp:SqlDataSource>
 
Post Your Reply If you still have problem, post it again under this reply for better response.

 
Sponsored by
SearchSAP
Everything You Know About CSS Is Wrong! - Free 37 Page Preview!
Washington Technology