0

I am adding table rows and table cells dynamically to a html table created static(tbleItems). It's alright. It;s working. My problem is I want to add another html table(tblCat) inside the table cell, But that table is not showing.. My code is here

       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);
    }}

1 Answer 1

0

You're creating the HtmlTableCell td7 but never adding it to any other controls.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.