|
Rank: Newbie Groups: Member
Joined: 9/29/2015 Posts: 3
|
Hi, I am using following code for HTML:
Code: HTML/ASPX
<%@ Register TagPrefix="eo" Namespace="EO.Web" Assembly="EO.Web" %>
<eo:CallbackPanel ID="CallbackPanel1" runat="server" Width="100%" AutoDisableContents="True" LoadingHTML='Please wait...'
Triggers="{ControlID:Button1;Parameter:}">
<asp:DataGrid ID="DataGrid1" runat="server" >
<asp:TemplateColumn HeaderText="Upload" HeaderStyle-Width="4%">
<ItemTemplate> <asp:FileUpload ID="UploadAttachment" runat="server" EnableViewState="true" /></ItemTemplate>
</asp:TemplateColumn>
</asp:DataGrid>
</eo:CallbackPanel>
Code behind:
Code: Visual Basic.NET
Private Sub Upload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
closeitems()
End Sub
Function closeitems() As String
For i = 0 To DataGrid1.Items.Count- 1
Dim fileUpload As FileUpload
fileUpload = CType(DataGrid1.Items(i).FindControl("UploadAttachment"), FileUpload)
' -************* PROBLEM COMES HERE ***********-
If fileUpload.HasFile Then
Dim filename As String = fileUpload.PostedFile.FileName
fileUpload.SaveAs(MapPath("~/Upload/") & filename)
Cmd.CommandText = String.Format("INSERT INTO TABLENAME VALUES({0}, '{1}', {2}, '{3}')", ItemNoValue, filename, DateTime.Now.ToString, Session("UserID"))
Cmd.CommandType = CommandType.Text
Cmd.ExecuteNonQuery()
End If
Conn.Close()
Next I
End Function
File upload controls are into the datarow of gridview. When I post back the form I am unable to find values/state of fileupload control. Please help me out of this problem. Thanks.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
I do not believe you can do this with FileUpload control. The FileUpload control must post back the whole page as multipart/form-data, where as the CallbackPanel always post back as application/x-www-form-urlencoded, which means the CallbackPanel can not post data for the FileUpload control back to the server.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 9/29/2015 Posts: 3
|
So what is the solution?
But we can do post files using Ajax Tool Kit Update Panel.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
The unfortunately truth is there is no solution to this. FileUpload and AJAX does not work together due to the underlying posting formats are different. It can not be done. So you just have to use a regular postback instead of an AJAX postback.
Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
smokepk wrote:So what is the solution?
But we can do post files using Ajax Tool Kit Update Panel. We are not aware of that. In that case you can probably use AJAX ToolKit UpdatePanel. Our CallbackPanel always post in application/x-www-form-urlencoded, that format can not carry file upload data. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 9/29/2015 Posts: 3
|
Well in that case let me help you :) I used EO.AjaxUploader (http://www.essentialobjects.com/Products/EOWeb/Uploader.aspx) it solves my problem. "The unfortunately truth is there is no solution to this" is not the good thing customer want to listen when they come out with solution.
|
|