I have file upload as an ItemTemplate in the gridview. I handle multiple file uploads using HttpFileCollection in the code behind. My problem is when I try to upload some files and iterate though the HttpFileCollection, the HttpFileCollection (Request.Files)
was always empty with a count of zero. I am using ASP.NET 3.5 SP1.
aa1803
Member
1 Points
12 Posts
The HttpFileCollection (Request.Files) is always empty with a count of zero.
Sep 20, 2008 07:04 PM|LINK
Hi,
I have file upload as an ItemTemplate in the gridview. I handle multiple file uploads using HttpFileCollection in the code behind. My problem is when I try to upload some files and iterate though the HttpFileCollection, the HttpFileCollection (Request.Files) was always empty with a count of zero. I am using ASP.NET 3.5 SP1.
Any help would be much appreciated.
Here are some snap of my aspx page
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true" HeaderText="List of validation errors" Font-Size="Small" /> <asp:Label ID="Label3" runat="server" Font-Size="Small" ForeColor="Red" /> <asp:DynamicValidator runat="server" ID="GridViewValidator" ControlToValidate="GridView1" Display="None" /> <br /> <table> <tr> <td> <asp:Label ID="Label1" Font-Size="Small" runat="server" Text="Fund: " AssociatedControlID="DynamicFilter$DropDownList1" /> </td> <td> <asp:DynamicFilter runat="server" ID="DynamicFilter" ContextTypeName="PiedmontDataContext" TableName="Investors" DataField="Fund" OnSelectedIndexChanged="OnFilterSelectedIndexChanged" /> </td> </tr> <tr> <td> <asp:Label ID="Label2" Font-Size="Small" runat="server" Text="Date: " /> </td> <td> <asp:TextBox ID="Date1" runat="server" Width="175" OnTextChanged="Date1_TextChanged" AutoPostBack="true" /> <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/Calendar_scheduleHS.png" /> <ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" Format="MM-dd-yyyy" TargetControlID="Date1" PopupButtonID="Image1"> </ajaxToolkit:CalendarExtender> </td> </tr> </table> <br /><br /><br /> <asp:GridView ID="GridView1" runat="server" DataSourceID="GridDataSource" AllowSorting="True" BorderColor="#E7E3E3" BorderWidth="1" CellPadding="10" AutoGenerateColumns="false" > <Columns> <asp:TemplateField HeaderText="Fund" SortExpression="FundName"> <ItemTemplate> <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "~/Funds/ListDetails.aspx?FundID=" + Eval("FundID")%>' Text='<%# Eval("FundName") %>' /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Investor" SortExpression="InvestorName"> <ItemTemplate> <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%# "~/Investors/Details.aspx?InvestorID=" + Eval("InvestorID")%>' Text='<%# Eval("InvestorName") %>' /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField ItemStyle-Width="300" HeaderText="Broswe Report" HeaderStyle-Font-Size="Small" > <ItemTemplate> <input id="File1" name="File1" type="file" size="23" runat="server" /> </ItemTemplate> </asp:TemplateField> </Columns> <EmptyDataRowStyle Font-Size="Small" /> <EmptyDataTemplate> There are currently no Investor in this fund. </EmptyDataTemplate> </asp:GridView> <asp:LinqDataSource ID="GridDataSource" runat="server" ContextTypeName="PiedmontDataContext" TableName="Investors" OnSelecting="GridDataSource_Selecting" > <WhereParameters> <asp:DynamicControlParameter ControlID="DynamicFilter" /> </WhereParameters> </asp:LinqDataSource> <br /> <asp:Button ID="Button1" Text="Upload All" OnClick="Button1_Click" runat="server" /> </ContentTemplate> </asp:UpdatePanel>HttpFileCollection
aa1803
Member
1 Points
12 Posts
Re: The HttpFileCollection (Request.Files) is always empty with a count of zero.
Sep 21, 2008 12:10 PM|LINK
I think I've managed to fix it. All I did was to take the Upload button outside the update panel.