Your usage of the loop is usual
if (count > 2)
{
while(i< objDT_Ad.Rows.Count)
{
PlaceHolder1.Controls.Add(new Literal { Text = objDT_Ad.Rows[i]["Particular"].ToString() });
count = 0;
i++;
break;
}
}
Since the loop don't loop, if simpler to use a
if
if (count > 2)
{
if (i< objDT_Ad.Rows.Count)
{
PlaceHolder1.Controls.Add(new Literal { Text = objDT_Ad.Rows[i]["Particular"].ToString() });
count = 0;
i++;
}
}
your sample code is not autonomous, not much can be devised from it. Would be better flesh up the code so that is can be run.
A sample of initial data and result you want would be nice too.