I have the following code
<asp:Content ID="headContent" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:DynamicDataManager ID="DynamicDataManager1" runat="server" AutoLoadForeignKeys="true">
<DataControls>
<asp:DataControlReference ControlID="FormView1" />
</DataControls>
</asp:DynamicDataManager>
<h2 class="DDSubHeader">
Edit entry from table
<%= table.DisplayName %></h2>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true"
HeaderText="List of validation errors" CssClass="DDValidator" />
<asp:DynamicValidator runat="server" ID="DetailsViewValidator" ControlToValidate="FormView1"
Display="None" CssClass="DDValidator" />
<asp:FormView runat="server" ID="FormView1" DataSourceID="DetailsDataSource" DefaultMode="Edit"
OnItemCommand="FormView1_ItemCommand" OnItemUpdated="FormView1_ItemUpdated" RenderOuterTable="false"
OnPageIndexChanging="FormView1_PageIndexChanging">
<EditItemTemplate>
<table id="detailsTable" class="DDDetailsTable" cellpadding="6">
<asp:DynamicEntity runat="server" Mode="Edit" />
<tr class="td">
<td colspan="2">
<asp:LinkButton runat="server" CommandName="Update" Text="Update" />
<asp:LinkButton runat="server" CommandName="Cancel" Text="Cancel" CausesValidation="false" />
<br />
</td>
<td>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Label ID="lblMessage" runat="server">
</asp:Label>
<asp:Button ID="btnUpload" runat="server" OnClick="btnUpload_Click" Text="Upload" />
</td>
</tr>
</table>
</EditItemTemplate>
<EmptyDataTemplate>
<div class="DDNoItem">
No such item.</div>
</EmptyDataTemplate>
</asp:FormView>
<asp:LinqDataSource ID="DetailsDataSource" runat="server" EnableUpdate="true" />
<asp:QueryExtender TargetControlID="DetailsDataSource" ID="DetailsQueryExtender"
runat="server">
<asp:DynamicRouteExpression />
</asp:QueryExtender>
</ContentTemplate>
</asp:UpdatePanel>
This file was generate using Dynamic Data. I am trying to add a file upload control in the form but in the code behind I can’t acces ‘FileUpload1’ to see if it contains elements.
How can I do that?
If I make a new form it works but I can’t get it out to work in my existing form.
<form id="form1" runat="server"></form>
It’s common issue.
You are trying to upload file on ajax request calling upload from update panel.
But you need full postback to upload it using serious FileUpload or look for javascript based file upload controls.