Reputation: 21
I have used Ajax fileupload control in gridview, to upload files for each record in the gridview. I used ajax fileupload control, because i needed the drag and drop upload facility too. Its working awesome. But now once a file is selected in each row i want to get file names from the fileupload controls which are in every row within the gridview.
I have googled alot, how i could get uploaded file names on a button by name "Next" click, but i found no solution. Here is my GridView with Ajax fileupload control.
<asp:GridView ID="gvImgsSelect" autogeneratecolumn="false" runat="server">
<Columns>
<asp:TemplateField HeaderText="Campus">
<ItemTemplate>
<asp:Label ID="lblCampusName" runat="server" Text="<%#Bind('campusName') %>"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Image1">
<ItemTemplate>
<asp:AjaxFileUpload ID="ajxFileUpload1" width="200px" MaximumNumberOfFiles="1" runat="server" AllowedFileTypes="jpg,jpeg,png,gif"/>
</ItemTemplate>
</asp:TemplateField>
</Columns> </asp:GridView>
<asp:Button ID="btnNext" runat="server" Text="Next" onclick="btnNext_Click" />
Upvotes: 2
Views: 2442
Reputation: 521
Have you tried this:
protected void ajxFileUpload1_OnUploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
{
// full path of uploaded file
string filePath = e.FileName;
// only file name of uploaded file
string fileName = Path.GetFileName(e.FileName);
}
Upvotes: 1