Hi @GaniTPT ,
I'm not sure that I understand your question, but I did notice a few things that don't look right. I don't think you need the loop through the ErrReport table. Maybe you want your loops to look more like this:
// The ErrorList needs to be created outside both loops
List<string> ErrorList = new List<string>();
foreach (int prod in mainproduct)
{
//Get sub product no from main data table (DTmainProduct). for example
string prodno = "102201";
string proname = "ALKO";
string ItemNo1 = "A-1001222";
foreach (DataRow DR in DTsubProduct.Rows)
{
//Get sub product no from main data table (DTsubProduct). for example
if ((ItemNo1==ItemNo2)
{
// You might be doing something if they match, I don't know
}
else
{
//if not matching the ItemNo, handling the error log
DataRow dr = ErrReport.NewRow();
ErrReport.Rows.Add(dr);
dr[0] = prodno;
dr[1] = proname;
}
}
}
Hope that helps.