display image in image control
Posted
by
KareemSaad
on Stack Overflow
See other posts from Stack Overflow
or by KareemSaad
Published on 2011-01-01T14:35:02Z
Indexed on
2011/01/01
14:54 UTC
Read the original article
Hit count: 309
I had Image control and I added code to display images But there is not any image displayed
ASPX:
<body>
<form id="form1" runat="server">
<div dir='<%= sDirection %>'>
<div id="ContentImage" runat="server">
<asp:Image ID="Image2" runat="server" />
</div>
</div>
</form>
</body>
C#:
using (System.Data.SqlClient.SqlConnection con = Connection.GetConnection())
{
string Sql = "Select Image From AboutUsData Where Id=@Id";
System.Data.SqlClient.SqlCommand com = new System.Data.SqlClient.SqlCommand(Sql, con);
com.CommandType = System.Data.CommandType.Text;
com.Parameters.Add(Parameter.NewInt("@Id", Request.QueryString["Id"].ToString()));
System.Data.SqlClient.SqlDataReader dr = com.ExecuteReader();
if (dr.Read() && dr != null)
{
Image1.ImageUrl = dr["Image"].ToString();
}
}
© Stack Overflow or respective owner