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

HtmlTableCell を作成していますtd7が、他のコントロールには追加していません。

于 2013-09-14T12:38:25.983 に答える