我正在尋找在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網頁形式 –