Issues when posting file with radasyncupload inside a datagrid

1 posts, 0 answers
  1. Gonzalo
    Gonzalo avatar
    1 posts
    Member since:
    Aug 2015

    Posted 26 Aug 2015 Link to this post


     I have a radasyncupload inside a datagrid footer. The files uploads to the temporary folder but when I check for UploadedFiles.Count on the Datagrid.ItemCommand event the count is 0.

    Is there a problem with using radasyncupload inside a datagrid control?


    <asp:datagrid id="grdDocumentUpload" runat="server" CssClass="GridStandard" CellPadding="3" ShowFooter="True" AutoGenerateColumns="False" DataKeyField="rupID" AllowSorting="true">
    <HeaderStyle CssClass="GridHeaderStandard"></HeaderStyle><ItemStyle CssClass="GridItemStyleStandard"></ItemStyle><br>    <AlternatingItemStyle CssClass="GridAlternatingItemStyleStandard"></AlternatingItemStyle><br>    <Columns><br>      <asp:TemplateColumn>        <br>        <FooterTemplate><br>          <asp:ImageButton id="imbAddDocumentUpload" Runat="server" ImageUrl="images/Icons/icoSave_Enabled.gif"<br>            CommandName="Add" AlternateText="Save New Upload"></asp:ImageButton><br>        </FooterTemplate>        <br>      </asp:TemplateColumn>    <br>     <br>      <asp:TemplateColumn HeaderText="File" SortExpression="rupUploadPath"><br>        <ItemTemplate><br>          <asp:HyperLink ID="hypUploadPath" Text='<%# DataBinder.Eval(Container.DataItem,"rupUploadPath") %>' Target="_blank" NavigateUrl='<%# DataBinder.Eval(Container.DataItem,"rupUploadPath") %>' CssClass="HyperlinkStandard" runat="server"></asp:HyperLink><br>        </ItemTemplate><br>        <FooterTemplate><br>          <%--<INPUT class="LabelStandard" id="filUploadFile" type="file" size="25" runat="server">--%><br>          <div class="qsf-demo-canvas"><br>            <telerik:RadAsyncUpload runat="server" ID="AsyncUpload1" HideFileInput="true" Skin="Silk" MultipleFileSelection="Automatic" PostbackTriggers="cmdSaveUpload" DropZones=".DropZone1" OnClientValidationFailed="validationFailed" UploadedFilesRendering="BelowFileInput" Localization-Select="Browse" TemporaryFolder="D:\Websites\Uploads\" /><br>            <div class="DropZone1">                    <br>                <p>Drop Files Here</p><br>            </div><br>          </div><br>        </FooterTemplate><br>      </asp:TemplateColumn><br>  </asp:datagrid>

    Private Sub grdDocumentUpload_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles grdDocumentUpload.ItemCommand
          ' Declare procedure scope variables
          Dim arySQL(0) As String
          Dim lngDocumentUploadID As Long
          Dim strErrorMessage As String = ""
          Dim filUploadPath As HtmlInputFile
          Dim txtDescription As TextBox
          Dim hypUploadPath As HyperLink
          Dim ddlUploadType As DropDownList
          Dim ddlClientAccess As DropDownList
          Dim strHTTP As String
          Dim chkRequireElectronicSignatureClient As CheckBox
          Dim chkRequireElectronicSignatureSpouse As CheckBox
          Dim AsyncUpload1 As Telerik.Web.UI.RadAsyncUpload
          ' Declare variables for file upload
          Dim strFileNamePath As String
          Dim strFileNameOnly As String
          Dim strFilePath As String
          Dim strExtension As String
          Dim lngCounter As Long = 1
          Dim lngLength As Long = 0
          Dim lngIndexOfPeriod As Long = 0
          Dim strTemporaryFileNameOnly As String
          Dim strUploadPath As String = ""
          Dim strFilename As String = ""
          ' Clear user search criteria
          lblMessage.Text = ""
          ' Get the HTTP
          If UCase(Request.ServerVariables("HTTPS")) = "ON" Then strHTTP = "https://" Else strHTTP = "http://"
          strHTTP = strHTTP & Request.ServerVariables("HTTP_HOST") & Request.ApplicationPath
          ' Get the upload path from web.config
            strUploadPath = ConfigurationManager.AppSettings("UploadPath").ToString
          Catch ex As Exception
            strUploadPath = ""
          End Try
          If e.CommandName = "Add" Then
            lngDocumentUploadID = 0
            AsyncUpload1 = CType(e.Item.FindControl("AsyncUpload1"), Telerik.Web.UI.RadAsyncUpload)
            If strErrorMessage = "" Then
              ' Check to make sure the file has been posted
              If AsyncUpload1.UploadedFiles.Count = 0 Then
                strErrorMessage = "You need to upload at least one file."
              End If
              For Each filFile As Telerik.Web.UI.UploadedFile In AsyncUpload1.UploadedFiles
                If filFile.FileName.ToString <> "" Then
                  'CODE TO SAVE THE FILE
                End If
              lblMessage.Text = strErrorMessage & "<br>"
              lblMessage.CssClass = "ErrorStandardBold"
            End If
          ElseIf e.CommandName = "Cancel" Then
            grdDocumentUpload.EditItemIndex = -1
            grdDocumentUpload.ShowFooter = True
            lblMessage.Text = ""
            lblMessage.CssClass = ""
          End If
        End Sub



    It always shows a count of 0 for the uploaded files count. If I move it outside of the datagrid it works.


    Please help.

Back to Top