protected void CreateTable()
    {
        TableRow tblrNewRow;
        TableCell tblcNewCell;

        int iRowNumber = 5;
        int iCellNumber = 5;

        for (int iRowIndex = 0; iRowIndex < iRowNumber; iRowIndex++)
        {
            tblrNewRow = new TableRow();

            for (int iCellIndex = 0; iCellIndex < iCellNumber; iCellIndex++)
            {
                tblcNewCell = new TableCell();

                if (iCellIndex == 1)
                {
                    TextBox tb = new TextBox();
                    tb.ID = "tb" + iRowIndex.ToString() + iCellIndex.ToString();
                    tb.Text = "tb" + iRowIndex.ToString() + iCellIndex.ToString();
                    tblcNewCell.Controls.Add(tb);
                }
                else if (iCellIndex == 3)
                {
                    int count = 0;
                    DropDownList dropNew = new DropDownList();
                    dropNew.ID = "drop" + iRowIndex.ToString() + iCellIndex.ToString();
                    for (int i = 0; i < 10; i++) dropNew.Items.Add(iRowIndex.ToString() + count++);
                    tblcNewCell.Controls.Add(dropNew);
                }
                else
                {
                    Button btn = new Button();
                    btn.ID = "btn" + iRowIndex.ToString() + iCellIndex.ToString();
                    btn.Text = "按钮" + iRowIndex.ToString() + iCellIndex.ToString();
                    btn.Click += new EventHandler(btn_Click);
                    tblcNewCell.Controls.Add(btn);
                }

                tblrNewRow.Cells.Add(tblcNewCell);
            }

            tblShopCar.Rows.Add(tblrNewRow);
        }
    }

相关文章:

  • 2022-12-23
  • 2021-12-07
  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
  • 2022-01-04
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-01
  • 2021-12-03
  • 2021-08-20
  • 2021-06-08
  • 2022-12-23
  • 2022-01-05
相关资源
相似解决方案