asim jan

asim jan

  • NA
  • 24
  • 28.7k

Repeater control with image in asp.net

Mar 30 2012 2:08 AM
hi
i have stored a table book_details which book_image column in sql server 2008 in image format
 

CREATE TABLE Book_Details(
[Book_id] [int] IDENTITY(1,1) NOT NULL,
[Book_Code] [varchar](15) NOT NULL,
[Book_Name] [varchar](100) NOT NULL,
[Book_Author] [varchar](30) NOT NULL,
[Book_Publisher] [varchar](100) NOT NULL,
[Book_Category] [varchar](50) NOT NULL,
[Book_Unit_Price] [money] NOT NULL,
[Book_Total_In_Stock] [int] NULL,
[Book_Image] [image] NULL,
[Book_Added_On] [datetime] NULL,
[Book_Summary] [varchar](5000) NOT NULL
)
 
i am using a repeater control in front end to display recently added books
 
in the repeater i want to display images along with the book details
 
kindly help
 
CODE FOR HOME.ASPX REPEATER
 
asp:Repeater runat="server" id="Repeater1" >
<HeaderTemplate>
<strong> Recently Added Books </strong>
</HeaderTemplate>
<SeparatorTemplate>
<hr />
</SeparatorTemplate>
<itemtemplate>
<separatortemplate>
<hr>
</separatortemplate>
<table>
<tr>
<td style="width:100px">
 

<img src= '<%# DataBinder.Eval(Container.DataItem, "Book_Image") %>.jpeg'
alt="" style="height:100px;width:100px;border:1px solid gray;"/>
</td>
<td >
<b><%# DataBinder.Eval(Container.DataItem, "Book_Name") %></b>
<br>Book Code: <%# DataBinder.Eval(Container.DataItem,"Book_Code", "{0Big Grin | :-D }") %>
<br>Author: <%# DataBinder.Eval(Container.DataItem,"Book_Author", "{0Big Grin | :-D }") %>
<br> Publisher: <%# DataBinder.Eval(Container.DataItem,"Book_Publisher", "{0Big Grin | :-D }")%>
<br /><asp:HyperLink runat="server" ID="Buy" NavigateUrl='<%# "View cart.aspx?t1=" +Eval("Book_Code") %>'>
Buy Now!!
</asp:HyperLink></td>
</tr>
</table>
</itemtemplate>
 
</asp:Repeater>
 

 
CODE FOR HOME.ASPX.CS TO FILL REPEATER
public void RecentlyAdded()
{
 
SqlConnection conn = new SqlConnection(Utility.GetConnectionString());
SqlDataAdapter adapter = new SqlDataAdapter("SELECT TOP 5 Book_Added_On,Book_Code ,Book_Name,Book_Author,Book_Publisher,Book_Unit_Price,Book_Total_In_Stock,Book_Image FROM Book_Details AS BD ORDER BY Book_Added_On desc", conn);
DataTable table = new DataTable();
adapter.Fill(table);
Repeater1.DataSource = table;
Repeater1.DataBind();
 

}
 
EVERY THING WORKS FINE BUT I AM NOT ABLE TO DISPLAY IMAGES IN REPEATER..
 
IT ONLY SHOWS BLANK THUMBNAILS...

Answers (2)