0

我正在将表格行和表格单元格动态添加到创建的静态(tbleItems)html 表格中。没关系。它正在工作。我的问题是我想在表格单元格中添加另一个 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);
    }}
4

1 回答 1

0

您正在创建 HtmlTableCelltd7但从未将其添加到任何其他控件。

于 2013-09-14T12:38:25.983 回答