List <List <string >>进入ASP表

时间:2019-12-01 05:25:43

标签: c# asp.net loops

我正在尝试将字符串列表中的数据作为ASP表元素中的行输入。所有正确的数据都将通过,但各行将自身重复3次。如何只添加一次到表元素?

List<List<string>> table =  NorthwindAccess.GetProducts(ddl_Supplier.SelectedItem.Value);

for (int i = 0; i < table.Count(); ++i)
{
    for (int k = 1; k < table[i].Count(); ++k)
    {                    
        row1  = new TableRow(); //create as many rows as in each column (name, quantity, stock)

        for (int j = 0; j < table.Count(); ++j)
        {
            string cellData = table[j][k];
            TableCell cells = new TableCell();
            cells.Text = cellData;
            row1.Cells.Add(cells);                        
        }

        ProductsTable.Rows.Add(row1);
    }
}

0 个答案:

没有答案