Can't to Able to Display Image
Hi Developers,I am try to display image, there is no error on my code . but the image only does not displaying.
Below is am adding my Source code.
1 . Aspx Code :
<div>
<asp:DataList ID="DataList1" runat="server" BackColor="Gray" BorderColor="#666666"
BorderStyle="None" BorderWidth="2px" CellPadding="3" CellSpacing="2"
Font-Names="Verdana" Font-Size="Small" GridLines="Both" RepeatColumns="3" RepeatDirection="Horizontal"
Width="600px">
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<HeaderStyle BackColor="#333333" Font-Bold="True" Font-Size="Large" ForeColor="White"
HorizontalAlign="Center" VerticalAlign="Middle" />
<HeaderTemplate>
Employee Details</HeaderTemplate>
<ItemStyle BackColor="White" ForeColor="Black" BorderWidth="2px" />
<ItemTemplate>
<asp:Image ID="imgEmp" runat="server" Width="100px" Height="120px" ImageUrl='<%# Bind("File") %>'
style="padding-left:40px"/><br />
</ItemTemplate>
</asp:DataList>
</div>
2. C# Code
protected void BindData()
{
OleDbConnection conn = Connection.DBconnection();
DataSet ds = new DataSet();
string cmdstr = "Select * from tbl_addnews where ststus='A'";
OleDbCommand cmd = new OleDbCommand(cmdstr, conn);
OleDbDataAdapter adp = new OleDbDataAdapter(cmd);
adp.Fill(ds);
DataList1.DataSource = ds.Tables[0];
DataList1.DataBind();
}
3. My Image inserted Code:
string path = Server.MapPath("~/");
string phy_path = "http://localhost:1570/STEELS%20GLOBEL%2023-04-2016/Admin/Add_News.aspx";
string FileUpload1_path = "";
string File1 = "";
if (FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "")
{
FileUpload1_path = "/FileUpload1/" + FileUpload1.PostedFile.FileName + getExtension(FileUpload1.FileName);
File1 = phy_path + "/FileUpload1/" + FileUpload1.PostedFile.FileName + getExtension(FileUpload1.FileName);
FileUpload1.SaveAs(path + FileUpload1_path);
}
OleDbConnection con = Connection.DBconnection();
int i = objadd.insert_news(txtcourse.Text.Trim().ToString(), File1);
if (i > 0)
{
lblmessage.Text = "Inserted Successfully";
cgv.EditIndex = -1;
bindgrid();
}
If I make any mistake or have to do any changes in my Source code please guide me.
Thanking You
Paul.S