Wednesday, 6 May 2015

Binding List to datagridview using LINQ


List<string> listFiles=new List<string>();
//FIll your list with data that you want to display in datagridview

documentsDataGridView.DataSource = listFiles.Select(x => new { ColmnName1 = Path.GetFileName(x), ColumnName2 = x }).ToList();

//This will create two columns in datagridview with the name as :-ColmnName1 /ColmnName2
 

No comments:

Post a Comment