HI,
I just came across good link and used that in my code..
how to bind list to datagridview
I used
List<String> list_string= new List<String>();
DataGridView.DataSource = list_string.Select(x => new { Value = x }).ToList();
And now i have my values in the datagrid.
to bind my list to datagrid,but how to reverse the process?
i.e.
i want to do something like this
List<string> myList = datagridview1.datasource as list<string>;
But i am getting myList==null doesn’t contain any element.
regards,
Sangram Nandkhile.
By doing
x => new { Value = x }you are projecting a new anonymous type and is no longer aList<string>In the same question your reference try and use the accepted answer and project out to a known type, that way you can retrieve the
List<StringValue>With that you can:
And than to finally get your
List<string>