image problem in datalist

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Aug 2007
Posts: 33
Reputation: ansari.wajid is an unknown quantity at this point 
Solved Threads: 0
ansari.wajid ansari.wajid is offline Offline
Light Poster

image problem in datalist

 
0
  #1
Jun 30th, 2008
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
---------------

<aspataList 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>
</aspataList>


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
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 61
Reputation: dskumar_85 is an unknown quantity at this point 
Solved Threads: 1
dskumar_85 dskumar_85 is offline Offline
Junior Poster in Training

Re: image problem in datalist

 
0
  #2
Jun 30th, 2008
Originally Posted by ansari.wajid View Post
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
---------------

<aspataList 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>
</aspataList>


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
hi shall i know whether u say

the image as a binary in database or ,

you save the image in front end and save the image path in database ,

if u reply for this i will help u out ,

because i to use this type in c# ,

so reply me soon ,i will reply u tomarrow ok ,,,

cool
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 33
Reputation: ansari.wajid is an unknown quantity at this point 
Solved Threads: 0
ansari.wajid ansari.wajid is offline Offline
Light Poster

Re: image problem in datalist

 
0
  #3
Jun 30th, 2008
I am saving path of the image in the database.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 33
Reputation: ansari.wajid is an unknown quantity at this point 
Solved Threads: 0
ansari.wajid ansari.wajid is offline Offline
Light Poster

Re: image problem in datalist

 
0
  #4
Jul 1st, 2008
problem is resolved. Actually I was storing the complete physical path of my application in the database like D:\something\myapplicating\images\img.jpg that is why images in datalist are not displayed. I changed the path to images\img.jpg and it worked. Hope this will help others
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the ASP.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC