This question is locked. New answers and comments are not allowed.
Hi,
i have a radupload that will perform a validate some fields value before upload the file. Wen the validation return false, i will cancel the upload and i want to get back the file list and display back to the radupload after cancel the upload. The reupload function return me an error.
{System.NullReferenceException: Object reference not set to an instance of an object.
at DragDropUpload.MainPage.ReUploadItems()}
what wrong of the code? and how can i display back the list of file that browsed?
The code example are below:-
i have a radupload that will perform a validate some fields value before upload the file. Wen the validation return false, i will cancel the upload and i want to get back the file list and display back to the radupload after cancel the upload. The reupload function return me an error.
{System.NullReferenceException: Object reference not set to an instance of an object.
at DragDropUpload.MainPage.ReUploadItems()}
what wrong of the code? and how can i display back the list of file that browsed?
The code example are below:-
Private Sub RadUpload1_UploadStarted(ByVal sender As Object, ByVal e As Telerik.Windows.Controls.UploadStartedEventArgs) Handles RadUpload1.UploadStarted
Dim list As New ObservableCollection(Of MyDatabaseService.clsImportDoc)
Try
If Not FormBase Is Nothing Then
Dim dgPF As New Grid
dgPF = CType(FormBase.FindName("dgProfileFields"), Grid)
For i As Integer = 0 To dgPF.Children.Count - 1
If TypeOf (dgPF.Children.Item(i)) Is TextBox Then
Dim txtPF As New TextBox
txtPF = CType(dgPF.Children.Item(i), TextBox)
list.Add(New clsImportDoc With {.ProfileFieldsNames = txtPF.Name.ToString, .ProfileFieldValues = txtPF.Text.ToString, .ProfileID = ddpProfile.SelectedValue})
ElseIf TypeOf (dgPF.Children.Item(i)) Is RadDatePicker Then
Dim rdpPF As New RadDatePicker
rdpPF = CType(dgPF.Children.Item(i), RadDatePicker)
list.Add(New clsImportDoc With {.ProfileFieldsNames = rdpPF.Name.ToString, .ProfileFieldValues = rdpPF.DateTimeText.ToString, .ProfileID = ddpProfile.SelectedValue})
End If
Next
End If
AddHandler client.fValidateIndexValueCompleted, AddressOf client_fValidateIndexValueCompleted
client.fValidateIndexValueAsync(list)
Catch ex As Exception
client.sWriteErrorLogAsync("RadUpload1_UploadStarted (MainPage Silverlight Import) : " & ex.Message)
End Try
End Sub
Private Sub client_fValidateIndexValueCompleted(ByVal sender As Object, ByVal e As fValidateIndexValueCompletedEventArgs)
Dim strValidateResult As String = ""
Try
strValidateResult = e.Result
If strValidateResult <> "1" Then
lblErrorMessage.Visibility = Windows.Visibility.Visible
lblErrorMessage.Content = strValidateResult
SaveFiles()
RadUpload1.CancelUpload()
ReUploadItems()
End If
Catch ex As Exception
client.sWriteErrorLogAsync("client_fValidateIndexValueCompleted (MainPage Silverlight Import) : " & ex.Message)
End Try
End Sub
Private files As New List(Of FileInfo)()
Private Sub ReUploadItems()
'/ put the files back in the upload
Try
If files.Count > 0 Then
For Each file As FileInfo In files
Dim f As New RadUploadSelectedFile(file)
RadUpload1.CurrentSession.SelectedFiles.Add(f)
Next
End If
Catch ex As Exception
End Try
End Sub
Private Sub SaveFiles()
'/ get the files from the upload.
'Dim files As New List(Of FileInfo)()
files.Clear()
For Each item As Object In RadUpload1.CurrentSession.SelectedFiles
files.Add(item.File)
Next
End Sub