Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Deleting multiple rows from a DataGrid
Message
From
11/02/2004 18:19:18
 
General information
Forum:
ASP.NET
Category:
Forms
Miscellaneous
Thread ID:
00876431
Message ID:
00876498
Views:
14
Victor,

Can you even select multiple rows in a DataGrid? I haven't used DataGrids much, but I can't find anything about selecting more than one row.

~~Bonnie


>I have a datagrid that I want to be able to select multiple rows and then delete them all at once. The problem I am running into is that for each row, I need to check certain column values to make sure that it is ok to delete it (business rules). Currently I have it working if I want to delete one row at a time. I have code that is something like this:
>
>Dim cm As CurrencyManager = CType(Me.BindingContext(dgFileInfo.DataSource, dgFileInfo.DataMember), CurrencyManager)
>
>' Retrieve the default DataView of the DataGrid
>Dim dv As DataView = CType(cm.List, DataView)
>
>' Use Currency Manager and DataView to retrieve the Current Row
>Dim dr As DataRow
>dr = dv.Item(cm.Position).Row
>
>I then do a check on a field in the datarow.
>
>If CType(dr("FileNumber"), String) = "" Then
>    dr.delete()
>Else
>    'Can't delete
>End If
>
>The above works fine for selecting one row and then deleting, but how would I do multiple rows and be able to check each row before I delete?
>
>Thanks,
>
>Vic
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform