The image will be store in database and you can bind the database with gridview
to upload an image take FileUpload Control
protected void btnUpload_Click(object sender, EventArgs e)
{
try
{
string filename = FileUpload1.FileName;
string fileExt = System.IO.Path.GetExtension(FileUpload1.FileName);
if (fileExt == ".jpg" || fileExt == ".gif" || fileExt == ".bmp" || fileExt == ".JPG" || fileExt == ".GIF" || fileExt == ".png" || fileExt == ".jpeg")
{
FileUpload1.PostedFile.SaveAs(Server.MapPath("~\\ThoughtForDay\\" + filename));
string path = "~\\ThoughtForDay\\" + filename;
SqlCommand cmd = new SqlCommand("Insert into ThoughtFortheDay(Imageurl,date1,date2) values('" + path + "',@date1,@date2)", cnn);
cmd.Parameters.AddWithValue("Imageurl",fileExt);
cmd.Parameters.AddWithValue("date1", txtdate1.Text);
cmd.Parameters.AddWithValue("date2", txtdate2.Text);
cmd.CommandType = CommandType.Text;
cnn.Open();
cmd.ExecuteNonQuery();
lblinfo.Text = "Uploaded Successfully";
cnn.Close();
}
else
{
lblinfo.Text = "Browse Only jpg,gif,bmp,png,jpeg Image File!";
}
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
ThoughtForDay is foledr name for images.
to show image in gridview see
Displaying Images in a GridView
isplaying Images in a GridView