How to Upload files,Save in folder and display in asp.net grid view with view and edit option?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Gowtham RajamanickamRank #57 · 29K reputationPosted May 2, 2015, 4:04 AM EDT
Dipankar BiswasRank #992 · 2K reputationPosted May 2, 2015, 4:07 AM EDT
protected void btn_up_new_img_Click(object sender, EventArgs e)
{
if (up_load_new_img.PostedFile.ContentLength > 0)
{
s1 = Path.GetFileName(up_load_new_img.FileName);
path = Server.MapPath("file_upload") + "/" + s1;
up_load_new_img.SaveAs(path);
}
SqlConnection ronicon = new SqlConnection(strConnString);
ronicon.Open();
SqlCommand ronicom = new SqlCommand("sp_up_img", ronicon);
ronicom.CommandType = CommandType.StoredProcedure;
ronicom.Connection = ronicon;
ronicom.Parameters.AddWithValue("@usr_name", lb1.Text);
ronicom.Parameters.AddWithValue("@usr_upload_image", s1);
ronicom.ExecuteNonQuery();
ronicom.Dispose();
save_and_show();
ronicon.Close();
}
SqlConnection ronicon = new SqlConnection();
SqlCommand ronicom = new SqlCommand();
SqlDataAdapter ronida;
DataTable ronidt;
private void save_and_show()
{
SqlConnection ronicon = new SqlConnection(strConnString);
ronicon.Open();
ronida = new SqlDataAdapter("select usr_upload_image from tbl_up_img ", ronicon);
ronidt = new DataTable();
ronida.Fill(ronidt);
ronida.Dispose();
GridView2.DataSource = ronidt;
GridView2.DataBind();
}
For your edit option... check this link..http://www.c-sharpcorner.com/UploadFile/1e050f/edit-and-update-record-in-gridview-in-Asp-Net/
thanks...
Yogendra YadavRank #4,815 · 324 reputationPosted May 2, 2015, 4:21 AM EDT