|
|
|
start date: Tue, 14 Aug 2007 19:06:00 -0000,
posted on: microsoft.public.dotnet.framework.aspnet
back
| Thread Index |
|
1
hplayer03
|
|
2
Alexey Smirnov
|
Displaying Images on a page
I am trying to create an asp.net 2.0 site that has the paths of images
stored in a sql database. I am able to connect to the database and
extract the paths. I am stuck now because i would like to dynamically
create images and set their paths to those that i find in the
database....here is the code to get the path names:
string connSTR =
ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString.ToString();
SqlConnection conn = new SqlConnection(connSTR);
SqlDataAdapter a = new SqlDataAdapter("SELECT path, name,
description FROM Pics;", conn);
DataSet s = new DataSet();
a.Fill(s);
string sImagePath = "";
foreach (DataRow dr in s.Tables[0].Rows)
{
sImagePath = dr[0].ToString() + dr[1].ToString();
}
Date:Tue, 14 Aug 2007 19:06:00 -0000
Author:
|
Re: Displaying Images on a page
On Aug 14, 9:06 pm, hplayer03 wrote:
> I am trying to create an asp.net 2.0 site that has the paths of images
> stored in a sql database. I am able to connect to the database and
> extract the paths. I am stuck now because i would like to dynamically
> create images and set their paths to those that i find in the
> database....here is the code to get the path names:
>
> string connSTR =
> ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString.ToString();
> SqlConnection conn = new SqlConnection(connSTR);
> SqlDataAdapter a = new SqlDataAdapter("SELECT path, name,
> description FROM Pics;", conn);
> DataSet s = new DataSet();
> a.Fill(s);
> string sImagePath = "";
> foreach (DataRow dr in s.Tables[0].Rows)
> {
> sImagePath = dr[0].ToString() dr[1].ToString();
> }
Try to use DataList or GridView. Otherwise you can simply
Panel1.Controls.Add(new LiteralControl("<img src.... "));
or
Response.Write("<img src....");
Date:Tue, 14 Aug 2007 12:45:40 -0700
Author:
|
|
|