Assuming that a list of Foo has been databound to FooGrid and a Foo has Bar and Baz properties...
protected void FooGrid_CommandButtonInitialize(object sender,
ASPxGridViewCommandButtonEventArgs e)
{
var grid = sender as ASPxGridView;
int barId = Convert.ToInt32(grid.GetRowValues(e.VisibleIndex, "Bar"));
int bazId = Convert.ToInt32(grid.GetRowValues(e.VisibleIndex, "Baz"));
...then the above will pull out the Bar and Baz properties for the given row to variables while the following will get the whole of the object collection back from the ASPxGridView assuming that Bar is the unique id for Foo.
void FooGrid_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
{
List<object> rawValues = FooGrid.GetSelectedFieldValues("Bar");
List<int> values = rawValues.Cast<int>().ToList();
var collection = values.Select(x => FooGrid.FindVisibleIndexByKeyValue(x))
.Select(y => FooGrid.GetRow(y) as Foo).ToList();
No comments:
Post a Comment