试试:
cb=(HtmlInputCheckBox)this.table_workplan .Rows[i].Cells[0].Controls(0);为何不用Web控件:DataGrid
然后用模版列就可以达到你要的效果

解决方案 »

  1.   

    用 web datagrid 方便
      

  2.   

    用DataGrid很容易实现,你尝试重构一下?
      

  3.   

    private void Page_Load(object sender, System.EventArgs e)
    {
    // Put user code to initialize the page here
    for(int i=0;i<10;i++)
    {
    HtmlTableRow myRow=new HtmlTableRow ();
    HtmlTableCell myCell_0=new HtmlTableCell ();
    HtmlTableCell myCell_1=new HtmlTableCell ();
    CheckBox box=new CheckBox();
    box.Text="复选框";
    box.ID="Check" + i;
    myCell_0.Controls.Add(box);
    myRow.Cells.Insert (0,myCell_0);
    myRow.Cells.Insert (1,myCell_1);
    this.Table1.Rows.Insert ((i+1),myRow);
    this.Table1.Rows[i+1].Cells[1].InnerText=i.ToString();
    }}
    private void Button1_Click(object sender, System.EventArgs e)
    {   
    TextBox1.Text = "";
    for(int i=0 ;i<10 ;i++)
    {
    CheckBox cb=this.Table1.Rows[i+1].Cells[0].FindControl("Check"+i) as CheckBox;
    if(cb.Checked ==true)
    {
    TextBox1.Text +=this.Table1.Rows[i+1].Cells[1].InnerText.ToString() +"-";
    }
    }
    }
      

  4.   

    看看
    http://msdn.microsoft.com/library/en-us/dndive/html/data05242001.asp?frame=true用datagrid 来做
      

  5.   

    这样会很麻烦的,每次页面回发时你都要执行一次生成Table的代码
    for(int i=0;i<10;i++)
    {
    HtmlTableRow myRow=new HtmlTableRow ();
    HtmlTableCell myCell_0=new HtmlTableCell ();
    HtmlTableCell myCell_1=new HtmlTableCell ();
    CheckBox box=new CheckBox();
    box.Text="复选框";
    box.ID="Check";
    myCell_0.Controls.Add(box);
    myRow.Cells.Insert (0,myCell_0);
    myRow.Cells.Insert (1,myCell_1);
    this.table_workplan .Rows .Insert ((i+1),myRow);
    this.table_workplan  Rows[i+1] .Cell[1].InnerText=i.Tostring();
    }
      

  6.   

    http://msdn.microsoft.com/library/en-us/dndive/html/data05242001.asp?frame=true