0

我有以下代码

<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>

该文件是使用动态数据生成的。我正在尝试在表单中添加文件上传控件,但在后面的代码中我无法访问“FileUpload1”以查看它是否包含元素。我怎样才能做到这一点?

如果我制作一个新表格,它可以工作,但我无法让它在我现有的表格中工作。

  <form id="form1" runat="server"></form> 
4

1 回答 1

0

这是常见的问题。您正在尝试从更新面板调用上传的 ajax 请求上传文件。但是您需要完整的回传才能使用严肃的 FileUpload 上传它,或者寻找基于 javascript 的文件上传控件。

于 2012-11-21T10:34:59.537 回答