We have a pretty simple grid, with a number of rows and a number of columns. In each cell we display a string. The first column contains checkboxes, by which the user can select one or more rows.
When the user clicks on a button, we want to do something - server side - with the data in the selected rows.
In the button click code-behind, I have a reference to the grid. With that reference, I can access SelectedItems. But for the life of me I can't figure out how to get the text values that are in the cells.
All of the examples I've been able to find, that pull data from the items, are passed the items in grid event functions. When the user clicks on our button, it doesn't generate an event on the grid, so we're not being passed the items, we need to get them from the grid object. The problem is that the grid events pass GridDataItems, and the grid control contains GridItems, so the access methods described for the one don't work for the other.
How can I access the selected GridDataItems from the grid control, other than in a grid event function?
OK, never mind...
RadGrid.SelectedItems contains GridItems. All I need do is cast them to GridDataItems, and I can access the text values of the items within it.
When the user clicks on a button, we want to do something - server side - with the data in the selected rows.
In the button click code-behind, I have a reference to the grid. With that reference, I can access SelectedItems. But for the life of me I can't figure out how to get the text values that are in the cells.
GridItemCollection selectedItems = grid.SelectedItems; |
foreach (GridItem selectedItem in selectedItems) |
{ |
// Then what? |
} |
All of the examples I've been able to find, that pull data from the items, are passed the items in grid event functions. When the user clicks on our button, it doesn't generate an event on the grid, so we're not being passed the items, we need to get them from the grid object. The problem is that the grid events pass GridDataItems, and the grid control contains GridItems, so the access methods described for the one don't work for the other.
How can I access the selected GridDataItems from the grid control, other than in a grid event function?
OK, never mind...
RadGrid.SelectedItems contains GridItems. All I need do is cast them to GridDataItems, and I can access the text values of the items within it.