You don't need to qualify the name try this...
Dim FileUpload1 As FileUpload = FormView1.FindControl("FileUpload1")
On 1/30/07, Rusdie Cavalera <[EMAIL PROTECTED]> wrote:
>
> Protected Sub Page_Load(ByVal sender As Object, ByVal
> e As System.EventArgs) Handles Me.Load
> If IsPostBack Then
> Dim path As String =
> Server.MapPath("~/Photo/")
> Dim fileOK As Boolean = False
>
> Dim FileUpload1 As FileUpload =
> FormView1.FindControl("FormView1$FileUpload1")
>
> If FileUpload1.HasFile Then
> Dim fileExtension As String
> fileExtension = System.IO.Path. _
>
> GetExtension(FileUpload1.FileName).ToLower()
> Dim allowedExtensions As String() = _
> {".jpg", ".jpeg", ".png", ".gif"}
> For i As Integer = 0 To
> allowedExtensions.Length - 1
> If fileExtension =
> allowedExtensions(i) Then
> fileOK = True
> End If
> Next
> If fileOK Then
> Try
>
> FileUpload1.PostedFile.SaveAs(path & _
> FileUpload1.FileName)
> Label1.Text = "File uploaded!"
> Catch ex As Exception
> Label1.Text = "File could not
> be uploaded."
> End Try
> Else
> Label1.Text = "Cannot accept files
> of this type."
> End If
> End If
> End If
> End Sub
>
> and HTML look like this:
> ------------------------
>
> <asp:Label ID="Label1" runat="server"
> Text="Label"></asp:Label><br />
> <br />
> <br />
> <asp:FormView ID="FormView1" runat="server"
> DataKeyNames="ID" DataSourceID="ObjectDataSource1">
> <EditItemTemplate>
> ID:
> <asp:Label ID="IDLabel1"
> runat="server" Text='<%# Eval("ID")
> %>'></asp:Label><br />
> Nama_Mobil:
> <asp:TextBox ID="Nama_MobilTextBox"
> runat="server" Text='<%# Bind("Nama_Mobil") %>'>
> </asp:TextBox><br />
> Merk:
> <asp:TextBox ID="MerkTextBox"
> runat="server" Text='<%# Bind("Merk") %>'>
> </asp:TextBox><br />
> Warna:
> <asp:TextBox ID="WarnaTextBox"
> runat="server" Text='<%# Bind("Warna") %>'>
> </asp:TextBox><br />
> Tahun:
> <asp:TextBox ID="TahunTextBox"
> runat="server" Text='<%# Bind("Tahun") %>'>
> </asp:TextBox><br />
> Tanggal:
> <asp:TextBox ID="TanggalTextBox"
> runat="server" Text='<%# Bind("Tanggal") %>'>
> </asp:TextBox><br />
> Keterangan:
> <asp:TextBox ID="KeteranganTextBox"
> runat="server" Text='<%# Bind("Keterangan") %>'>
> </asp:TextBox><br />
> Status:
> <asp:TextBox ID="StatusTextBox"
> runat="server" Text='<%# Bind("Status") %>'>
> </asp:TextBox><br />
> Image_File:
> <asp:TextBox ID="Image_FileTextBox"
> runat="server" Text='<%# Bind("Image_File") %>'>
> </asp:TextBox><br />
> <asp:LinkButton ID="UpdateButton"
> runat="server" CausesValidation="True"
> CommandName="Update"
> Text="Update">
> </asp:LinkButton>
> <asp:LinkButton
> ID="UpdateCancelButton" runat="server"
> CausesValidation="False" CommandName="Cancel"
> Text="Cancel">
> </asp:LinkButton>
> </EditItemTemplate>
> <InsertItemTemplate>
> Nama_Mobil:
> <asp:TextBox ID="Nama_MobilTextBox"
> runat="server" Text='<%# Bind("Nama_Mobil") %>'>
> </asp:TextBox><br />
> Merk:
> <asp:TextBox ID="MerkTextBox"
> runat="server" Text='<%# Bind("Merk") %>'>
> </asp:TextBox><br />
> Warna:
> <asp:TextBox ID="WarnaTextBox"
> runat="server" Text='<%# Bind("Warna") %>'>
> </asp:TextBox><br />
> Tahun:
> <asp:TextBox ID="TahunTextBox"
> runat="server" Text='<%# Bind("Tahun") %>'>
> </asp:TextBox><br />
> Tanggal:
> <asp:TextBox ID="TanggalTextBox"
> runat="server" Text='<%# Bind("Tanggal") %>'>
> </asp:TextBox><br />
> Keterangan:
> <asp:TextBox ID="KeteranganTextBox"
> runat="server" Text='<%# Bind("Keterangan") %>'>
> </asp:TextBox><br />
> Status:
> <asp:TextBox ID="StatusTextBox"
> runat="server" Text='<%# Bind("Status") %>'>
> </asp:TextBox><br />
> Image_File:
> <asp:FileUpload ID="FileUpload1"
> runat="server" />
> <asp:Button ID="Button1"
> runat="server" Text="Button" /><br />
> <asp:LinkButton ID="InsertButton"
> runat="server" CausesValidation="True"
> CommandName="Insert"
> Text="Insert">
> </asp:LinkButton>
> <asp:LinkButton
> ID="InsertCancelButton" runat="server"
> CausesValidation="False" CommandName="Cancel"
> Text="Cancel">
> </asp:LinkButton>
> </InsertItemTemplate>
> <ItemTemplate>
> ID:
> <asp:Label ID="IDLabel" runat="server"
> Text='<%# Eval("ID") %>'></asp:Label><br />
> Nama_Mobil:
> <asp:Label ID="Nama_MobilLabel"
> runat="server" Text='<%# Bind("Nama_Mobil") %>'>
> </asp:Label><br />
> Merk:
> <asp:Label ID="MerkLabel"
> runat="server" Text='<%# Bind("Merk")
> %>'></asp:Label><br />
> Warna:
> <asp:Label ID="WarnaLabel"
> runat="server" Text='<%# Bind("Warna")
> %>'></asp:Label><br />
> Tahun:
> <asp:Label ID="TahunLabel"
> runat="server" Text='<%# Bind("Tahun")
> %>'></asp:Label><br />
> Tanggal:
> <asp:Label ID="TanggalLabel"
> runat="server" Text='<%# Bind("Tanggal")
> %>'></asp:Label><br />
> Keterangan:
> <asp:Label ID="KeteranganLabel"
> runat="server" Text='<%# Bind("Keterangan") %>'>
> </asp:Label><br />
> Status:
> <asp:Label ID="StatusLabel"
> runat="server" Text='<%# Bind("Status")
> %>'></asp:Label><br />
> Image_File:
> <asp:Label ID="Image_FileLabel"
> runat="server" Text='<%# Bind("Image_File") %>'>
> </asp:Label><br />
> <asp:LinkButton ID="EditButton"
> runat="server" CausesValidation="False"
> CommandName="Edit"
> Text="Edit">
> </asp:LinkButton>
> <asp:LinkButton ID="DeleteButton"
> runat="server" CausesValidation="False"
> CommandName="Delete"
> Text="Delete">
> </asp:LinkButton>
> <asp:LinkButton ID="NewButton"
> runat="server" CausesValidation="False"
> CommandName="New"
> Text="New">
> </asp:LinkButton>
> </ItemTemplate>
> </asp:FormView>
> <asp:ObjectDataSource ID="ObjectDataSource1"
> runat="server" DeleteMethod="Delete"
> InsertMethod="Insert"
> OldValuesParameterFormatString="original_{0}"
> SelectMethod="GetMobil"
>
> TypeName="MotorTableAdapters.tb_MobilTableAdapter"
> UpdateMethod="Update">
> <DeleteParameters>
> <asp:Parameter Name="Original_ID"
> Type="Int32" />
> </DeleteParameters>
> <UpdateParameters>
> <asp:Parameter Name="Nama_Mobil"
> Type="String" />
> <asp:Parameter Name="Merk"
> Type="String" />
> <asp:Parameter Name="Warna"
> Type="String" />
> <asp:Parameter Name="Tahun"
> Type="String" />
> <asp:Parameter Name="Tanggal"
> Type="DateTime" />
> <asp:Parameter Name="Keterangan"
> Type="String" />
> <asp:Parameter Name="Status"
> Type="String" />
> <asp:Parameter Name="Image_File"
> Type="String" />
> <asp:Parameter Name="Original_ID"
> Type="Int32" />
> </UpdateParameters>
> <InsertParameters>
> <asp:Parameter Name="Nama_Mobil"
> Type="String" />
> <asp:Parameter Name="Merk"
> Type="String" />
> <asp:Parameter Name="Warna"
> Type="String" />
> <asp:Parameter Name="Tahun"
> Type="String" />
> <asp:Parameter Name="Tanggal"
> Type="DateTime" />
> <asp:Parameter Name="Keterangan"
> Type="String" />
> <asp:Parameter Name="Status"
> Type="String" />
> <asp:Parameter Name="Image_File"
> Type="String" />
> </InsertParameters>
> </asp:ObjectDataSource>
>
> </div>
>
> __________________________________________________________
> Never miss an email again!
> Yahoo! Toolbar alerts you the instant new Mail arrives.
> http://tools.search.yahoo.com/toolbar/features/mail/
>
>
--
Dean Fiala
Very Practical Software, Inc
Now with Blogging...
http://www.vpsw.com/blogbaby
Microsoft MVP
[Non-text portions of this message have been removed]