Click here to Skip to main content
16,004,806 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Dear friends,

I have list of files from folder in repeater with checkbox.
i need to delete checkbox checked items.

I got an error:
System.ArgumentException: The path is not of a legal form.


What I have tried:

For Each gvrow As RepeaterItem In rptBackups.Items
            Dim chkdelete As CheckBox = DirectCast(gvrow.FindControl("chkSelect"), CheckBox)
            If chkdelete.Checked Then
                Dim filePath As String = CType(sender, LinkButton).CommandArgument
                File.Delete(filePath)
                Response.Redirect(Request.Url.AbsoluteUri)
            End If
        Next



Solved Issue:

For Each MyControl As RepeaterItem In rptBackups.Items
           Dim filename As String = CType(MyControl.FindControl("Label1"), Label).Text
           Dim filePaths As String = "D:/FTP/DB Backup/" & filename
           Dim chkdelete As CheckBox = DirectCast(MyControl.FindControl("chkSelect"), CheckBox)
           If chkdelete.Checked Then
               File.Delete(filePaths)
           End If
       Next
Posted
Updated 10-Apr-17 3:07am
v2
Comments
ZurdoDev 10-Apr-17 8:02am    
You need to fix the path.
Jochen Arndt 10-Apr-17 8:06am    
The error is quite clear. Check the retrieved strings by printing them out, debugging the application, or what CommandArgument property has been set for the sender LinkButton.

But there is no need for a loop here because your are repeatedly retrieving the same value from your sender LinkButton.
Vivek.anand34 10-Apr-17 8:10am    
Actually its a single row delete code. i need to multiple rows delete option using checkbox. i modified that is an error. please can u modify it..
.
Jochen Arndt 10-Apr-17 8:17am    
I - and others - can't help without seeing the missing code portions and what kind of information is stored where.

If you have checkboxes in your rows, each row should also have a field containing the file name.
Vivek.anand34 10-Apr-17 8:26am    
Yes, each rows contains filenames, download button, checkbox...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900