Dear Friend,
In my Asp.Net c# application
we are creating datatable with 10K records and 120 columns, it is tacking more than 2 hours to complete the datatable.
THe following is the code i am using please help me out
foreach (DataColumn dc in policyLevelTable.Columns)
{
for (int i = 1; i <= 10000; i++)
{
if (dc.ColumnName.ToLower() == "policyid")
{
DataRow newdr = policyLevelTable.NewRow();
newdr[0] = i;
policyLevelTable.Rows.Add(newdr);
}
else
{
DataRow[] dr = policyLevelTable.Select("policyid in (" + i + ")");
dr[0][dc.ColumnName] = RandomParameterType(new List<int>{1,2,3,4}, 0, false);
}
}
}
Thanks,
Ramu.
What I have tried:
foreach (DataColumn dc in policyLevelTable.Columns)
{
for (int i = 1; i <= 10000; i++)
{
if (dc.ColumnName.ToLower() == "policyid")
{
DataRow newdr = policyLevelTable.NewRow();
newdr[0] = i;
// newdr[1] = 1;
policyLevelTable.Rows.Add(newdr);
}
else
{
DataRow[] dr = policyLevelTable.Select("policyid in (" + i + ")");
dr[0][dc.ColumnName] = RandomParameterType(new List<int> { 1, 2, 3, 4 }, 0, false);
}
}
}