I am trying to display image in repeater but image is not getting display
<asp:Image ID="Image1" runat="server" style="width:250px;height:250px" ImageUrl='<%# Eval("pro_image") %>' />
protected void Button1_Click(object sender, EventArgs e)
{
float c = Convert.ToInt64(TextBox3.Text);
product p = new product();
p.pro_name = TextBox1.Text;
p.pro_date = TextBox2.Text;
p.pro_price = c;
p.pro_img = img_upload(FileUpload1, Session["admin_id"].ToString());
p.pro_catid_fk = Convert.ToInt32(DropDownList1.SelectedValue.ToString());
p.pro_adminid_fk = Convert.ToInt32(Session["admin_id"].ToString());
insert i = new insert();
string k = i.insert_tblproduct(p);
if (k == "-1")
{
Label2.Text = "TRY AGAIN ....";
}
else
{
Label2.Text = "Ad successfully posted!";
}
}
public string img_upload(FileUpload FileUpload1, string id)
{
string s = " ";
if (FileUpload1.HasFile)
{
// Get the file extension
string fileExtension = System.IO.Path.GetExtension(FileUpload1.FileName);
if (fileExtension.ToLower() != ".png" && fileExtension.ToLower() != ".jpg")
{
Label2.ForeColor = System.Drawing.Color.Red;
Label2.Text = "Only files with .doc and .docx extension are allowed";
}
else
{
// Get the file size
int fileSize = FileUpload1.PostedFile.ContentLength;
// If file size is greater than 2 MB
if (fileSize > 2097152)
{
Label2.ForeColor = System.Drawing.Color.Red;
Label2.Text = "File size cannot be greater than 2 MB";
}
else
{
Random r = new Random();
int x = r.Next(0, 100000);
s = "~/images/" + FileUpload1.FileName + id.ToString() + x.ToString();
// Upload the file
FileUpload1.SaveAs(Server.MapPath(s));
Label2.ForeColor = System.Drawing.Color.Green;
Label2.Text = "File uploaded successfully";
}
}
}
else
{
Label2.ForeColor = System.Drawing.Color.Red;
Label2.Text = "Please select a file";
}
return s;
}
Please guide