I am dynamically creating a table on the client side and populating it with a list of peoples names.
sbData.Append("<table>");
int iColumnCounter = 1;
sbData.Append("<tr>");
foreach (int _iPerId in lsiPeople)
{
if (iColumnCounter == 5)
{
iColumnCounter = 1;
sbData.Append("</tr><tr>");
}
string sName = GetPersonName(_iPerId);
DropDownList_Student.Items.Add(new ListItem(sName, _iPerId.ToString()));
sbData.AppendFormat("<td><input class=\"studentCheckBox\" type=\"checkbox\" onClick=\"UpdateSelectedCounter()\" id={0} name=\"{1}\" value={0}>{1}</td>", _iPerId, sName);
iColumnCounter++;
}
sbData.Append("</tr>");
sbData.Append("</table>");
The names are already sorted in alphabetical order but it as you can see this will enter them in left to right jumping a column. When when it gets to 4 columns it will go to the next row.
I want it to go, top to bottom in a column, then to the next column so it will be like
______
|A|C|L|
|A|F|N|
|C|K|N|
Imagine these letters are the first letter of the persons second name.
If you want a 4×4 table, going down alphabetically then the index will be as follows:
So what you want to do is something like this: