我正在寻找在html表格中显示我的列表,或者我可以设置样式的输出。C#在样式表中显示列表
下面是我的代码和图片的链接,显示了我想要实现的目标。 每个订单#应该有自己的表。
我最初使用中继器,但因为我需要将具有相同ID的项目分组,所以我无法正确显示它。
谢谢。
public class myProducts
{
public int Order { get; set; }
public string Date { get; set; }
public string Qty { get; set; }
public string GrandTotal { get; set; }
public string Ship_FirstName { get; set; }
public string Ship_LastName { get; set; }
public string Item { get; set; }
public string Options { get; set; }
}
List<myProducts> products = new List<myProducts>();
myProducts product = new myProducts
{
Order = 1111,
Date = "5/8/2017",
Qty = "2",
GrandTotal = "$50.00",
Ship_FirstName = "John",
Ship_LastName = "Doe",
Item = "Item 4",
Options = "Option1, Option2, Option3, Option4",
};
products.Add(product);
product = new myProducts
{
Order = 1111,
Date = "5/8/2017",
Qty = "2",
GrandTotal = "$50.00",
Ship_FirstName = "John",
Ship_LastName = "Doe",
Item = "Item 4",
Options = "Option1, Option2, Option3, Option4",
};
products.Add(product);
product = new myProducts
{
Order = 34556,
Date = "5/9/2017",
Qty = "2",
GrandTotal = "$200.00",
Ship_FirstName = "John",
Ship_LastName = "Doe",
Item = "Item 4",
Options = "Option1, Option2, Option3, Option4",
};
products.Add(product);
product = new myProducts
{
Order = 143566,
Date = "5/2/2017",
Qty = "2",
GrandTotal = "$100.00",
Ship_FirstName = "John",
Ship_LastName = "Doe",
Item = "Item 4",
Options = "Option1, Option2, Option3, Option4",
};
products.Add(product);
var groups = products.GroupBy(x => new { x.Order, x.GrandTotal, x.Date, x.Ship_FirstName, x.Ship_LastName });
foreach (var group in groups)
{
var line1 = "Order # " + group.Key.Order + " <br />" + "Order Placed: " + group.Key.Date + " <br />" + " Total: " + group.Key.GrandTotal + " <br />" + " Ship To: " + group.Key.Ship_FirstName + " " + group.Key.Ship_LastName;
Line1.Text = Line1.Text + " <br /> " + line1.ToString() ;
foreach (var item in group)
{
var line2 = " -- Item: " +item.Item + " <br /> " + "-- Options: " + item.Options;
Line1.Text = Line1.Text + " <br /> " + line2.ToString();
}
}
平台? Winform/ASP web Form/MVC? –
@MAdeelKhalid对不起,ASP.net网页形式 –