as i have placed an image control with in a repeater control.. and i want to add different images to the image control how can i acheive this? please help me.....
<%#Eval("Moviename") %>
<%#Eval("cast") %>
this is the code, hope you have got the task.. please help me... thanks in advance
Raunak JhawarPosted Jan 27, 2010, 3:09 AM
You can create a image handler which will retrieve image file stored in the back end database
it might look like this:
try
{
cmd.CommandText = "Select * from ImageDisplayDB" +
" where ID=@ID";
cmd.CommandType = System.Data.CommandType.Text;
cmd.Connection = con;
SqlParameter ImageID = new SqlParameter("@ID", System.Data.SqlDbType.Int);
ImageID.Value = context.Request.QueryString["ID"];
cmd.Parameters.Add(ImageID);
dReader = cmd.ExecuteReader();
dReader.Read();
context.Response.BinaryWrite((byte[])dReader["imageFile"]);
}
And in the aspx listing:
<ItemTemplate>
<asp:Label ID="IDLabel" runat="server" Text='<%# Eval("imageName") %>' />
<br />
<asp:Image ID="Image1" runat="server"
ImageUrl='<%# "Handler1.ashx?ID=" + Eval("ID")%>'/>
<br />
<asp:CheckBox ID="CheckBox1" runat="server" Text="Select to delete" />
<%--
<br />
ItemTemplate>