display image in image control
- by KareemSaad
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();
}
}