добавить элемент списка Asp.net между ячейками таблицы. Когда я пытаюсь добавить список Radiobutton List, список всех элементов списка, идущих последним td цикла. Но я хочу сделать каждый элемент списка в моем внутреннем цикле td. Я добавил код ниже. Мой снимок экрана ниже. Может кто-нибудь, пожалуйста, помогите мне в этом. Добавить элемент RadioButtonList в td, используя цикл
var noofroom = (from row2 in dt2.AsEnumerable()
where (Int64)row2["hotelcode"] == hotelcode
select row2.Field<string>("guests")).Distinct();
var noofroom2 = (from row3 in dt2.AsEnumerable()
where (Int64)row3["hotelcode"] == hotelcode
select row3.Field<string>("noofroom")).Distinct();
int a = 1;
foreach (var rcount in noofroom)
{
foreach (var rcount2 in noofroom2)
{
DataRow[] drs = dt2.Select("hotelcode='" + hotelcode + "' AND noofroom='" + rcount2 + "' and guests='"+rcount+"'");
int numberOfRecords = dt2.Select("hotelcode='" + hotelcode + "' AND noofroom='" + rcount2 + "' and guests='" + rcount + "'").Length;
if (numberOfRecords != 0)
{
PlaceHolder1.Controls.Add(new LiteralControl("<div class='rhead'>" +
"Room " + a + "" +
"</div>" +
"<table class='roomtbl'>" +
"<tr>" +
"<td class='tdaltbg'>" +
"<strong> " +
"Board Type</strong></td>" +
"<td class='style30'>" +
"<strong> " +
"Room Type</strong></td>" +
"<td class='tdaltbg'>" +
"<strong> Room Price</strong></td>" +
"<td class='style30'>" +
"<strong> " +
"Sleep Up To</strong></td>" +
"<td class='tdaltbg'>" +
"<strong></strong></td>" +
"</tr>"));
}
RadioButtonList RadioButtonList1 = new RadioButtonList();
RadioButtonList1.ID = hotelcode.ToString() + rcount.ToString()+rcount2.ToString();
foreach (DataRow dr in drs)
{
PlaceHolder1.Controls.Add(new LiteralControl("<tr>" +
"<td class='tdaltbg'>" +
" " +
"" + dr["board"] + "</td>" +
"<td class='style30'>" +
"" + dr["roomtype"] + "</td>" +
"<td class='tdaltbg'>" +
" " +
"£ " + dr["amount"] + "</span></td>" +
"<td class='style30'>" +
" " +
" " + dr["guests"] + " Guests</span></td>" +
"<td class='tdaltbg'>"));
//RadioButtonList1.ID = hotelcode.ToString();
ListItem li = new ListItem();
li.Value = dr["amount"].ToString();
li.Text = "";
RadioButtonList1.Items.Add(li);
PlaceHolder1.Controls.Add(RadioButtonList1);
PlaceHolder1.Controls.Add(new LiteralControl("" +
"</td>" +
"</tr>"));
}
RadioButtonList1.SelectedIndex = 0;
PlaceHolder1.Controls.Add(new LiteralControl("</table>"));
a++;
}
}