By this code I got list of selected rows in AspxGrid.
string[] fieldName = new string[] { "UserId", "Name", "Address" };
List<object> SelectedList = Grid.GetSelectedFieldValues(fieldName);
Now I want to perform one of the below operation.
List<object>
into List<Users>
I have tried following two methods but Exception occurs.
Unable to cast object of type 'System.Object[]' to type 'CubeDataObject.Claims'.
List<Users> mylist = (List<Users>)(Object)SelectedList;
List<Users> listd = SelectedList.Select(n => (Users)n).ToList();
I have also tried so many other methods too but tired.
For this simple tast the Cast
-extension-method on Enumerable
exists:
var myList = SelectedList.Cast<User>();
Now you can easily filter:
var result = myList.Where(x => x.userId == 1);