943,740 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Marked Solved
  • Views: 2510
  • ASP.NET RSS
Jun 30th, 2008
0

image problem in datalist

Expand 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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
ansari.wajid is offline Offline
47 posts
since Aug 2007
Jun 30th, 2008
0

Re: image problem in datalist

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
Reputation Points: 9
Solved Threads: 1
Junior Poster in Training
dskumar_85 is offline Offline
69 posts
since Mar 2008
Jun 30th, 2008
0

Re: image problem in datalist

I am saving path of the image in the database.
Reputation Points: 10
Solved Threads: 0
Light Poster
ansari.wajid is offline Offline
47 posts
since Aug 2007
Jul 1st, 2008
0

Re: image problem in datalist

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
Reputation Points: 10
Solved Threads: 0
Light Poster
ansari.wajid is offline Offline
47 posts
since Aug 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Using a Timer Control
Next Thread in ASP.NET Forum Timeline: problem related to DropDownList, AutoPostBack





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC