FileUpload missing

Apr 14 2015 4:02 AM
why when I just update the name of the institution, FileUpload missing

Default.aspx
 
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CssClass="GridStyle" Width="1100px" DataKeyNames="id_lembaga"
  onrowediting="edit" onrowupdating="update" onrowcancelingedit="batal">
  <Columns>
  <asp:BoundField DataField="propinsi_nama" HeaderText="Provinsi" />
  <asp:BoundField DataField="kabupaten_nama" HeaderText="Kabupaten/Kota" />
  <asp:BoundField DataField="sektor_nama" HeaderText="Sektor" />
  <asp:TemplateField HeaderText="Nama Lembaga">
  <ItemTemplate>
  <asp:Label ID="Label1" runat="server" Text='<%#Eval("nama_lembaga") %>'></asp:Label>
  </ItemTemplate>
  <EditItemTemplate>
  <asp:TextBox ID="txtnmlembaga" runat="server" TextMode="MultiLine" Text='<%#Eval("nama_lembaga") %>'></asp:TextBox>
  </EditItemTemplate>
  </asp:TemplateField>
  <asp:TemplateField HeaderText="Tugas & Fungsi">
  <ItemTemplate>
  <asp:Label ID="Label2" runat="server" Text='<%#Eval("tugas_fungsi") %>'></asp:Label>
  </ItemTemplate>
  <EditItemTemplate>
  <asp:DropDownList ID="droptugas" runat="server">
  <asp:ListItem></asp:ListItem>
  <asp:ListItem Text="Operator" Value="Operator"></asp:ListItem>
  <asp:ListItem Text="Regulator" Value="Regulator"></asp:ListItem>
  <asp:ListItem Text="Keduanya" Value="Keduanya"></asp:ListItem>
  </asp:DropDownList>
  </EditItemTemplate>
  </asp:TemplateField>
  <asp:TemplateField HeaderText="Struktur Organisasi">
  <ItemTemplate>
    <asp:Label runat="server" Text='<%#Eval("peraturan_terkait") %>'></asp:Label>
 
  </ItemTemplate>
  <EditItemTemplate>
  <asp:FileUpload ID="FileUpload1" runat="server" /> 
  </EditItemTemplate>
  </asp:TemplateField>
 
  <asp:CommandField ShowEditButton="true" HeaderText="Edit/Update" ButtonType="Button" />
  </Columns>
 
  </asp:GridView>
 
Default.aspx.cs
 
protected void update(object sender, GridViewUpdateEventArgs e)
  {
  MySqlConnection con = new MySqlConnection(strConnString);
 
  string id_lembaga = GridView1.DataKeys[e.RowIndex].Value.ToString();
  TextBox nmlembaga = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtnmlembaga");
  DropDownList droptugas = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("droptugas");
  FileUpload FileUpload1 = (FileUpload)GridView1.Rows[e.RowIndex].FindControl("FileUpload1");
  string path = "~/peraturan/";
 
  if (FileUpload1.HasFile)
 
  {  
  path += FileUpload1.FileName;
  FileUpload1.SaveAs(MapPath(path));  
  }  
  MySqlCommand cmd = new MySqlCommand("UPDATE tbl_nama_lembaga SET nama_lembaga='" + nmlembaga.Text + "',tugas_fungsi='" + droptugas.Text + "', peraturan ='" + path + "'  where id_lembaga=" + id_lembaga + "", con);
 
  con.Open();
  cmd.ExecuteNonQuery();
  con.Close();
  GridView1.EditIndex = -1;
  load_data();
  bindgridview();
 
  }


Answers (3)