class Student
{
public Id {get;set;}
public Name {get;set;}
}
List<Student> studentList = new List<Student>{st1,st2,st3,st4,st5};
DataGridView dgvStudentName
:
(Check) Id Name
true S01 Andrea
false S02 Mark
true S03 Selena
true S04 Bob
false S05 Mike
I tried to get selectList from studentList
which has DataGridViewCheckBoxCell is true in dgvStudentName
(checked by user) (Ex: st1,st3,st4).
I used LinQ to get what I want:
List<Student> selectList = dgvStudentName.Cast<DataGridViewRow>()
.Where(x=>(bool)x.Cells[0].Value == true)
.Select(x=>studentList.Where(q=>q.Id)==x.Cell[1].Value.ToString())
....
But it seems to be a stupid code. Could anyone help me?
Thank you in advanced!