I use a RadGrid control in an ASP.net project. This is a grid control from Telerik UI.I have an instance of this control and i want to iterate through it's SelectedItems
.
it's something like this:
RadGrid mygrd
foreach (GridDataItem item in mygrd.SelectedItems)
{
//Do Something with item
}
mygrd.SelectedItems
is a collection of GridDataItem. Every GridDataItem has columns witch are are defined in the control. Now i want to exclude an specific item with an specific value in one of it's columns. something like this:
foreach (GridDataItem item in mygrd.SelectedItems (Except if item["column1"] == "somethingSpecfic"))
{
//Do Something with item
}
I am looking a convenient way if exists, so not to use IF ELSE
. Also I was Looking to use Some LINQ, But actually there is no where
method under SelectedItems
.
Just use conditional statement:
foreach (GridDataItem item in mygrd.SelectedItems) {
if(item["column1"] != ”somethingSpecific”)
//Do Something with item
}
UPDATE:
okay, here is LINQ version, as asked in comments
foreach (GridDataItem item in mygrd.SelectedItems.Where(i => i["column1"] != ”somethingSpecific”)) {
//Do Something with item
}