This is a migrated thread and some comments may be shown as answers.

Fileexplorer reload on postback

1 Answer 62 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 03 Jul 2014, 05:49 PM
I have a file explorer on my page that is filtering files based on a sql pull.  However what happens is that I use the async uploader to upload files then show in only grid view in the file explorer.  When I post back though nothing show in the file explorer, it says no files avialable even though I uploaded files or there where previous files in there.






Protected Sub lnkSubmitRequest_Click(sender As Object, e As EventArgs) Handles lnkSubmitRequest.Click
 
Code to submit the page
 
This statment reloads all the information on the page if its changed from the database
  LoadPriorService(Convert.ToInt32(HFRecruit.Value))
 End If
 
 
 Private Sub LoadRecruit(ByVal recruitId As Integer)
 
Reload the page
 
This statement is where the FileExplorer is located on the LoadPriorService but I have no command to actually reload the control on a postback.
  LoadPriorService(recruitId)
        Else
            ScriptManager.RegisterClientScriptBlock(Page, GetType(Page), "OpenWindow", "NoData();", True)
        End If
 
 
 
  Private Sub LoadPriorService(ByVal recruit As Integer)
        ClearPriorSvc()
 
        sql = "Select intPriorServiceId, intBranchServiceId, dtDischarge, bitSF180, bitStaterequest, bitArpercen, bitredd, strNotes, dtSubmitted, submittedBy, dtCompleted, CompletedBy, strRocComments " _
            & "from vw_PriorService where intRecruitId = " & recruit
 
        myDataTable = New DataTable
        myDataTable = getReader(sql)
 
        If myDataTable.Rows.Count > 0 Then
            HFPriorService.Value = myDataTable.Rows(0)(0)
            ddlBranchService.SelectedValue = myDataTable.Rows(0)(1)
            txtDtDischarge.Text = myDataTable.Rows(0)(2)
 
            If myDataTable.Rows(0)(3) = "1" Then
                cbSF180.Checked = True
            End If
 
            If myDataTable.Rows(0)(4) = "1" Then
                cbState.Checked = True
            End If
 
            If myDataTable.Rows(0)(5) = "1" Then
                cbArpercen.Checked = True
            End If
 
            If myDataTable.Rows(0)(6) = "1" Then
                cbREDD.Checked = True
            End If
 
            txtPriorNotes.Text = myDataTable.Rows(0)(7)
            lblSubmittedON.Text = myDataTable.Rows(0)(8)
            lblSubmittedBy.Text = myDataTable.Rows(0)(9)
            lblCompletedOn.Text = myDataTable.Rows(0)(10)
            lblCompletedBy.Text = myDataTable.Rows(0)(11)
            txtRocNotes.Text = myDataTable.Rows(0)(12)
            lnkSubmitRequest.Enabled = True
        Else
            lblSubmittedON.Text = "None Submitted"
            lblSubmittedBy.Text = "None Submitted"
        End If
    End Sub
 
 
Here is the code that loads the fileExplorer, it seems to only load on the initial page loads and bugs out on postback.
 
  Private Sub radFileExplorer_ExplorerPopulated(sender As Object, e As RadFileExplorerPopulatedEventArgs) Handles radExplorer.ExplorerPopulated
 
        'If HFPriorService.Value > "" Then
        sql = "Select strUrl from PriorServiceUpload where intPriorServiceId = " & HFPriorService.Value
 
        myDataTable = New DataTable
        myDataTable = getReader(sql)
 
        If myDataTable.Rows.Count > 0 Then
            If e.ControlName = "grid" Then
                Dim items As List(Of FileBrowserItem) = e.List
                Dim i As Integer = 0
                For Each row As DataRow In myDataTable.Rows
                    While i < items.Count
                        If Not items(i).Name.Contains(row(0)) Then
                            items.Remove(items(i))
                        Else
                            i += 1
                        End If
                    End While
                Next
            End If
        End If
        'End If
    End Sub

1 Answer, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 09 Jul 2014, 07:24 AM
Hi Kevin,

I examined the provided code thoroughly and I believe I found the possible cause of the problem. Based on the information both in your other ticket and here, I assume the issue is coming from the following piece of code:
                For Each row As DataRow In myDataTable.Rows
                    While i < items.Count
                        If Not items(i).Name.Contains(row(0)) Then
                            items.Remove(items(i))
                        Else
                            i += 1
                        End If
                    End While
                Next

Basically, having the current implementation, FileExplorer will render only the files containing the the data from the first row, because the others will be removed after the first cycle. Following the same logic FileExplorer will not show any files if the name of the uploaded one does not match the one in the first row of MyDataTable.

A possible way to modify your implementation could be:
Protected Sub radFileExplorer_ExplorerPopulated(sender As Object, e As RadFileExplorerPopulatedEventArgs)
    If e.ControlName = "grid" Then
        Dim items As List(Of FileBrowserItem) = e.List
        Dim filteredItems As New List(Of FileBrowserItem)()
 
        Dim userdId As List(Of String) = New List(Of String)() From {"loading", "1234"} 'your logic here
        For Each id As String In userdId
            For i As Integer = 0 To items.Count - 1
                If items(i).Name.Contains(id) Then
                    filteredItems.Add(items(i))
                End If
            Next
        Next
 
        e.List = filteredItems
    End If
End Sub

Hope this helps.

Regards,
Vessy
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
FileExplorer
Asked by
Kevin
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Share this question
or