For example in my database there are 96 rows and what I want to happen is to group rows by four(the resulting table will have 3 columns with 8 rows). ex
Asked
Active
Viewed 973 times
1 Answers
2
You might have a much easier time if you can get away with a control other than a DataList. For instance, you could use a Table
server control like this:
<asp:Table ID="tblGrouped" runat="server"></asp:Table>
And then in code:
protected void LoadData() {
var items = MyDataSource.GetMyItems();
TableRow tr = null;
TableCell tc = null;
for (int i = 0; i < items.Count; i++) {
if (i % 12 == 0) {
tr = new TableRow();
tc = new TableCell();
tc.Text = items[i].MyProperty;
tr.Cells.Add(tc);
tblGrouped.Rows.Add(tr);
} else if (i % 4 == 0) {
tc = new TableCell();
tc.Text = items[i].MyProperty;
tr.Cells.Add(tc);
} else {
tc.Text += "<br />" + items[i].MyProperty;
}
}
}

hmqcnoesy
- 4,165
- 3
- 31
- 47