I have a little piece of code that is a little bit unoptimized and need some help with optimization in this case.
The procedure is to search in a database using "Conditions/Condicao" and create a grid using tables in HTML with content. In debug, the following part is taking a long time to complete with 300 results or more.
for (x = 0; x < Campos.Length; x++)
{
string concat = "";
for (i = 0; i < 2; i++)
{
if (concat != "")
{
concat += "," + oDrc[y].ItemArray[1].ToString().Trim().Replace("'", "");
}
else
{
concat += oDrc[y].ItemArray[0].ToString().Trim().Replace("'", "");
}
}
if (!pkunica)
{
concat = "";
for (i = 0; i < Pks.Length; i++)
{
if (concat != "")
{
concat += "," + oDrc[y].ItemArray[i].ToString().Trim().Replace("'", "");
}
else
{
concat += oDrc[y].ItemArray[i].ToString().Trim().Replace("'", "");
}
}
}
I've uploaded the full code to Pastebin. And about some words, they're in PT-BR.