2015-03-22 2 views
1

У меня есть gridview, внутри которого есть элемент управления AjaxFileUpload в каждой строке, чтобы пользователь мог прикрепить несколько файлов. Проблема в том, что я не могу найти элемент управления AjaxFileUpload внутри gridview.AJAX Multiple FileUpload внутри Gridview

код GridView:

<asp:GridView ID="gridview1" runat="server"> 
<Columns> 
    <asp:TemplateField ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="200px"> 
    <ItemTemplate> 
     <asp:AjaxFileUpload ID="fupReports" runat="server" MaximumNumberOfFiles="10" OnUploadComplete="fupReports_UploadComplete" Width="300px" /> 
    </ItemTemplate> 
    </asp:TemplateField> 
</Columns> 
</asp:GridView> 

Codebehind:

Protected Sub fupReports_UploadComplete(sender As Object, e As AjaxFileUploadEventArgs) 
    Dim filename As String = e.FileName 
    Dim dstnPath As String = System.IO.Path.GetTempPath 
    Dim fupReports As AjaxFileUpload = TryCast(gridview1.FindControl("fupReports"), AjaxFileUpload) 

    fupReports.SaveAs(dstnPath + filename) 

End Sub 

ответ

0

Мое решение:

Protected Sub fupReports_UploadComplete(sender As Object, e As AjaxFileUploadEventArgs) 

    Dim filename As String = e.FileId 
    TryCast(sender, AjaxFileUpload).SaveAs(Server.MapPath("uploads/") + filename) 

End Sub 
Смежные вопросы