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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Yogendra YadavPosted May 2, 2015, 8:21 AM
Dipankar BiswasPosted May 2, 2015, 8:07 AM
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...
Gowtham RajamanickamPosted May 2, 2015, 8:04 AM