我正在动态地将表行和表格单元添加到创建静态的html表(tbleItems)。没关系。它的工作。我的问题是我想在表格单元格中添加另一个html表格(tblCat),但该表格没有显示..我的代码在这里
private void loadItems()
{
DataTable dtCart = (DataTable)Session["Cart"];
for (int i = 0; i < dtCart.Rows.Count; i++)
{
string ticketID = dtCart.Rows[0]["ticketID"].ToString();
string sql = "select tk.userID, th.name as 'theater', md.name as 'movie', sh.showDate, sh.showTime, md.picURL";
sql += " from tbTicket tk, tbSchedule sh, tbMovieDrama md, tbTheater th ";
sql += " where tk.schID=sh.schID and sh.movieID=md.movieID and sh.theaterId=th.theaterID and tk.ticketID='" + ticketID + "'";
DataTable dtTicketDetails = obj.retrieveData(sql);
HtmlTableRow tr = new HtmlTableRow();
//Item No
HtmlTableCell td1 = new HtmlTableCell();
Label lblNo = new Label();
lblNo.Text = (i+1).ToString();
td1.Controls.Add(lblNo);
tr.Controls.Add(td1);
//Item Image
HtmlTableCell td2 = new HtmlTableCell();
Image img = new Image();
img.ImageUrl = dtTicketDetails.Rows[0]["picURL"].ToString();
img.Width=95;
img.Height = 68;
td2.Controls.Add(img);
tr.Controls.Add(td2);
//MovieName
HtmlTableCell td3 = new HtmlTableCell();
Label lblMov = new Label();
lblMov.Text = dtTicketDetails.Rows[0]["movie"].ToString();
td3.Controls.Add(lblMov);
tr.Controls.Add(td3);
//TheaterName
HtmlTableCell td4 = new HtmlTableCell();
Label lblTheater = new Label();
lblTheater.Text = dtTicketDetails.Rows[0]["theater"].ToString();
td4.Controls.Add(lblTheater);
tr.Controls.Add(td4);
//TheaterDate
HtmlTableCell td5 = new HtmlTableCell();
Label lblDate = new Label();
lblDate.Text = dtTicketDetails.Rows[0]["showDate"].ToString();
td5.Controls.Add(lblDate);
tr.Controls.Add(td5);
//TheaterTime
HtmlTableCell td6 = new HtmlTableCell();
Label lblTime = new Label();
lblTime.Text = dtTicketDetails.Rows[0]["showTime"].ToString();
td6.Controls.Add(lblTime);
tr.Controls.Add(td6);
//seatDetails
HtmlTableCell td7 = new HtmlTableCell();
HtmlTable tblCat = new HtmlTable();
//category table row1(headings)
HtmlTableRow trheadings = new HtmlTableRow();
HtmlTableCell tcCat = new HtmlTableCell();
tcCat.InnerText = "Category";
trheadings.Cells.Add(tcCat);
HtmlTableCell tcFull = new HtmlTableCell();
tcFull.InnerText = "Full";
trheadings.Cells.Add(tcFull);
HtmlTableCell tcHalf = new HtmlTableCell();
tcHalf.InnerText = "Half";
trheadings.Cells.Add(tcHalf);
tblCat.Rows.Add(trheadings);
td7.Controls.Add(tblCat);
tbleItems.Rows.Add(tr);
}}
答案 0 :(得分:0)
您正在创建HtmlTableCell td7
,但从未将其添加到任何其他控件。