hello master .net why if I update fileupload1, then FileUplo

Feb 11 2015 1:19 AM
pleas helpme

this my code

 protected void Updatedata(object sender, GridViewUpdateEventArgs e)
{
 FileUpload FileUpload1 = (FileUpload)GridView1.Rows[e.RowIndex].FindControl("FileUpload1");
        FileUpload FileUpload2 = (FileUpload)GridView1.Rows[e.RowIndex].FindControl("FileUpload2");

string id_peraturan = GridView1.DataKeys[e.RowIndex].Value.ToString();

string path1 = "Pembentukan/";
 string path2 = "Pengelolaan/";

 if (FileUpload1.HasFile)
        {
            path1 += FileUpload1.FileName;
            FileUpload1.SaveAs(MapPath(path1));
        }
  if (FileUpload2.HasFile)
        {
            path2 += FileUpload2.FileName;
            FileUpload2.SaveAs(MapPath(path2));
        }

 MySqlConnection con = new MySqlConnection(strConnString);

        MySqlCommand cmd = new MySqlCommand("UPDATE tbl_peraturan SET perda_pembentukan='" + path1 + "',perda_pengelolaan='"+ path2 +"' WHERE id_peraturan=" + id_peraturan + "", con);
  con.Open();
        cmd.ExecuteNonQuery();
        con.Close()
 GridView1.EditIndex = -1;
        tampilgird();
       Response.Redirect(Request.Url.AbsoluteUri);


}

Answers (4)