ok i now it supose to be simple y have a multidimensional array, I try to fill my data table using the following code:
System.Data.DataTable _myDataTable =new System.Data.DataTable();
for (int j=0; j < ele; j++)
{
_myDataTable.Columns.Add();
for (int i = 0; i < caract+1; i++)
{
row[i]=(datar[j,i].ToString());
}
_myDataTable.Rows.Add(row);
}
My array name is datar but the error I receive:
System.IndexOutOfRangeException: cant find column 1.
What am I doing wrong? By the way: I am using C#, asp.net, NOT Visual Studio.
As pointed out by chiffre you actually have 3 problems: You will have to add all columns before you can start to add rows and you will have to create a
DataRowbefore you can add it to yourDataTable. Your third problem is your row-dimension countercaract+1which will yield an IndexOutOfRange exception.