Basically I'm writing a program that through a form let's a person Upload an Image of a Tool and later on in another Page is able to View the Tools & Their Information in which one of the Columns is the Image.
Here is the Code I am using to 'Place' the Image in the GridView;
<asp:TemplateField HeaderText="Image">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Image") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Image ID="Image1" runat="server" Height="100px" Width="100px"
ImageUrl='<%#"data:Image/png;base64," + Convert.ToBase64String((byte[])Eval("ImageData")) %>'></asp:Image>
</ItemTemplate>
</asp:TemplateField>
Now I am stuck at how to able to Use the following SQL Command to be able to populate my GridView Column 'Image'.
I tried to look up some Tutorials but most of them have a whole table dedicated to Images and therefore use the Sql Command Select * FROM tblImages
and then populate the whole table in a GridView.
In my Case I just want the SQL to Take 1 Column from my Table and Populate it in 1 GridView Column.
private void LoadImages()
{
string cs = ConfigurationManager.ConnectionStrings["ToolsConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(cs))
{
SqlCommand cmd = new SqlCommand("Select Images from Tools",con);
con.Open();
SqlDataReader rdr = cmd.ExecuteReader();
GridView1.
}
}
Thanks for the Help!