【问题标题】:AJAX Multiple FileUpload inside GridviewGridview 中的 AJAX 多文件上传
【发布时间】:2015-05-25 12:49:23
【问题描述】:

我有一个gridview,里面的每一行都有一个AjaxFileUpload 控件供用户附加多个文件。问题是我无法在 gridview 中找到 AjaxFileUpload 控件。

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>

代码隐藏:

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

【问题讨论】:

    标签: asp.net ajax vb.net gridview


    【解决方案1】:

    我的解决方案:

    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
    

    【讨论】:

      猜你喜欢
      • 2014-11-12
      • 2011-10-31
      • 2017-08-02
      • 2012-05-04
      • 1970-01-01
      • 2019-01-11
      • 1970-01-01
      • 1970-01-01
      • 2012-05-24
      相关资源
      最近更新 更多