I know how to upload and insert using FileUpload ToolBox control.
But these time I have to insert selected gridView item(an image) to mysql using asp.net.
My codes are given below.
How can I fix it?
Examples will be much appriciated.
protected void ImageInsert()
{
{
MySqlConnection con = new MySqlConnection(constr);
MySqlCommand cmd = new MySqlCommand("INSERT INTO Images(Image) VALUES ('"+CheckBox().ToString()+"')", con);
con.Open();
int s1 = cmd.ExecuteNonQuery();
if (s1 > 0)
{
imgUp1.Text = "Image Uploaded succesfully!";
}
con.Close();
}
}
private string CheckBox()
{
string url=null;
foreach (GridViewRow row in gvImages.Rows)
{
CheckBox chkBox = row.FindControl("chkRow") as CheckBox;
if (chkBox !=null && chkBox.Checked)
{
Image img = (Image)row.Cells[1].Controls[1];
url = img.ImageUrl;
}
}
return url;
}
Loading

Francis SusaimichaelRank #466 · 5.4K reputationPosted Sep 30, 2015, 3:00 AM EDT
abhi lash108 reputationPosted Sep 30, 2015, 4:19 AM EDT
Raja TRank #685 · 3.5K reputationPosted Sep 30, 2015, 4:24 AM EDT
Sujeet SumanRank #790 · 2.9K reputationPosted Sep 30, 2015, 8:47 AM EDT
abdujalil chulievRank #4,912 · 319 reputationPosted Oct 2, 2015, 8:43 AM EDT