Binding DataGridView using Mutidimension Array

I would like to share a way by which we can bind Datagridview using Multidimension array.

Steps

a. Defining Array

string[][] Array = new string[100][];

b. Setting Values


for(int i = 0; i < 100; i++) {

 Array[i] = new string[2] { "ROLI:"+i, "DEVESH:"+i };

 
c. Binding Datagridview using Linq

dataGridView1.DataSource = (
from arr in Array select new { Column_1 = arr[0], Column_2 = arr[1] }).ToList();

 
Ebook Download
View all
Learn
View all