0

我已经转换xmlDataTable. 我有一个datatable类似的这样的。它描述了一家特定酒店的客房选择。如果板子类型、房间类型、房价相同,我想把它分成两个房间。

Room 1

Boards Type            Room Type            Room Price     Sleep Up To

Room Only              Double Standard        301.280       2 Guests    

Room Only              Double Standard        301.280       2 Guests    

我想让它像这样。

Room 1

Boards Type            Room Type            Room Price     Sleep Up To

Room Only              Double Standard        301.280       2 Guests  

Room 2

Boards Type            Room Type            Room Price     Sleep Up To

Room Only              Double Standard        301.280       2 Guests  

以下是我的代码,我尝试使用没有客人的情况来打破它。在那之后,我发现仅使用没有客人来打破它是不正确的方法。所以我想用 3 列打破这个并想打印为房间 2。

PlaceHolder1.Controls.Add(new LiteralControl("<div class='type1 pd10-lr pd15-tb'>"));

                var noofroom = (from row2 in dt2.AsEnumerable()
                                where (Int64)row2["hotelcode"] == hotelcode
                                     select row2.Field<string>("guests")).Distinct();

                int a = 1;

                foreach (var rcount in noofroom)
                {


                        PlaceHolder1.Controls.Add(new LiteralControl("<div class='rhead'>" +
                 "Room " + a + "" +
                 "</div>" +
                            "<table class='roomtbl'>" +
                         "<tr>" +
                             "<td class='tdaltbg'>" +
                                 "<strong>&nbsp;" +
                             "Board Type</strong></td>" +
                             "<td class='style30'>" +
                                 "<strong>&nbsp;" +
                             "Room Type</strong></td>" +
                             "<td class='tdaltbg'>" +
                                 "<strong>&nbsp;&nbsp; Room Price</strong></td>" +
                                 "<td class='style30'>" +
                                 "<strong>&nbsp;" +
                             "Sleep Up To</strong></td>" +
                             "<td class='tdaltbg'>" +
                                 "<strong></strong></td>" +
                         "</tr>"));

                        DataRow[] drs = dt2.Select("hotelcode='" + hotelcode + "' AND guests='" + rcount + "'");
                        foreach (DataRow dr in drs)
                        {
                            PlaceHolder1.Controls.Add(new LiteralControl("<tr>" +
                                  "<td class='tdaltbg'>" +
                                     "&nbsp;" +
                                     "" + dr["board"] + "</td>" +
                                "<td class='style30'>" +
                                     "" + dr["roomtype"] + "</td>" +
                                 "<td class='tdaltbg'>" +
                                     "&nbsp;" +
                                     "£ " + dr["amount"] + "</span></td>" +
                                       "<td class='style30'>" +
                                     "&nbsp;" +
                                     " " + dr["guests"] + " Guests</span></td>" +
                                 "<td class='tdaltbg'>"));

                            PlaceHolder1.Controls.Add(new LiteralControl("<input type='radio' name='t1' data-price='308.560' checked='checked'/>" +
                                 "</td>" +

                             "</tr>"));
                        }
                        PlaceHolder1.Controls.Add(new LiteralControl("</table>"));
                        a++;

                }
4

1 回答 1

0

请试试这个。这里可以将多个列作为参数传递,而 true 则表示不同。

于 2013-07-29T06:47:36.563 回答