Hi All
I am working since 2 days to display images in a datalist and the code used is given below, but its not displaying the images.
I am storing path of the image in database in imagepath cooumn. Kindly help me please.
html code
<asp:DataList ID="dlImage" runat="server" RepeatColumns="3" Width="311px" Height="334px">
<ItemTemplate>
<asp:ImageButton ID="imgPhotos" ImageUrl='<%#Eval("imagepath")%>' Height="100%" Width="100%" runat="server" />
</ItemTemplate>
</asp:DataList>
c# code
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
cnOledb = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" + strRootDir + "App_Data\\dbPhotos.mdb");
cnOledb.Open();
string strSelImages = "select imagepath from tblPhotos";
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(strSelImages, cnOledb);
da.Fill(ds);
dlImage.DataSource = ds.Tables[0];
dlImage.DataBind();
cnOledb.Close();
}
}
Thanks
wajid