Displaying Images on a page

H

hplayer03

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();
}
 
A

Alexey Smirnov

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"].Connecti­onString.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....");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top