Ok, so we want to display some information about a record, and one of the columns in that database has the picture we want to display.
So, say we want to display some information - say about a fighter.
So, say this simple markup:
<div class="mybox" style="float:left">
<div style="text-align: center; padding: 2px 10px 12px 10px">
<h3 id="Fighter" runat="server"></h3>
<asp:Image ID="Image2" runat="server"
Width="180" Height="120" />
<h4>Engine</h4>
<asp:Label ID="EngineLabel" runat="server" Text="" />
<h4>Description</h4>
<asp:Label ID="DescLabel" runat="server" width="400px"
Text="" style="text-align:left" Font-Size="Large" />
</div>
</div>
And code behind is this:
protected void Page_Load(object sender, EventArgs e)
{
// assume previous calling page
// set PK ID in sesion
if (!IsPostBack)
{
LoadInfo();
}
}
void LoadInfo()
{
int PK = (int)Session["FighterID"];
using (SqlConnection conn = new SqlConnection(Properties.Settings.Default.TEST4))
{
string strSQL =
"SELECT * FROM Fighters WHERE ID = @ID";
using (SqlCommand cmdSQL = new SqlCommand(strSQL, conn))
{
cmdSQL.Parameters.Add("@ID", SqlDbType.Int).Value = PK;
conn.Open();
DataTable dtFigher= new DataTable();
dtFigher.Load(cmdSQL.ExecuteReader());
DataRow dr = dtFigher.Rows[0];
Fighter.InnerText = dr["Fighter"].ToString();
EngineLabel.Text = dr["Engine"].ToString();
DescLabel.Text = dr["Description"].ToString();
Image2.ImageUrl = dr["ImagePath"].ToString();
}
}
}
And now we get/see this:

So, you are free to add a path name, and it depends on if you saved just the filename, or that you include the path name with the image.
However, the above should give you the basic idea here as to how you can pull a record, fill out some controls on the web page, including that of a image control.