[英]How to populate asp.net table with two linked lists
我创建了自定义链表,我希望通过其内容填充asp.net表。 这是我用来填充表格的代码:
void FillTriangleInRectangleTableRectangles(LinkList<Rectangle> AllRectangle, LinkList<Triangle> AllTriangles)
{
AllTriangles.Sort();
AllRectangle.Sort();
for (AllRectangle.Begining(), AllTriangles.Begining(); AllRectangle.Exist() && AllTriangles.Exist(); AllRectangle.Right(), AllTriangles.Right())
{
AddRow(TriaInsideTable, AllRectangle.ReturnFigure(), AllTriangles.ReturnFigure());
}
}
void AddRow(Table TableToFill, Rectangle rectangle, Triangle triangle)
{
TableRow row = new TableRow();
TableCell RectangleInfo = new TableCell();
RectangleInfo.Text = rectangle.ToString();
row.Cells.Add(RectangleInfo);
TableCell TriangleInfo = new TableCell();
TriangleInfo.Text = triangle.ToString();
row.Cells.Add(TriangleInfo);
TableToFill.Rows.Add(row);
}
但这对于我的循环看起来有点混乱,我实现了IEnumerable接口到LinkList类,我想使用foreach循环来填充表。 表应如下所示: 所以我的问题是 - 我该怎么做?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.