解决方案 »

  1.   

    问题是我要怎么获取生成的textbox的ID?
      

  2.   

    "我要怎么获取生成的textbox的ID? "这个可以直接设置吧  亲
      

  3.   


    textbox动态生成,没法设置他的ID啊。难道ID就是 textbox1 textbox2这样连续生成下去的?
      

  4.   

    TextBox tb = new TextBox();
                tb.ID = "txtTest";
      

  5.   


    textbox动态生成,没法设置他的ID啊。难道ID就是 textbox1 textbox2这样连续生成下去的?你给textbox的ID自动连续生成就像textbox1 textbox2
      

  6.   


    textbox动态生成,没法设置他的ID啊。难道ID就是 textbox1 textbox2这样连续生成下去的?你给textbox的ID自动连续生成就像textbox1 textbox2在用 Request.Form["textbox1"]来获取文本里的值
      

  7.   

    CreateTableRow() 你就不能在这个方法里传个序号什么的作为id 么?CreateTableRow(int index) 
     然后每个textbox 的id 后缀 可以使用这个序号“text_”+index
      

  8.   

    foreach (TableRow row in Table2.Rows)
            {
                int i = 0;
                i++;
                a = "insert into GongshiTongji(序号,用工部门,用工岗位,学号,姓名,工时,酬金,学院,专业班级)values('" + i.ToString() + "','" + (Table2.FindControl("Bbumen"+i.ToString()) as TextBox).Text + "','" + (Table2.FindControl("Bgangwei"+i.ToString()) as TextBox).Text + "','" + (Table2.FindControl("Bxuehao"+i.ToString()) as TextBox).Text + "','" + (Table2.FindControl("Bxingming"+i.ToString()) as TextBox).Text + "','" + (Table2.FindControl("Bgongshi"+i.ToString()) as TextBox).Text + "','" + (Table2.FindControl("Bchoujin"+i.ToString()) as TextBox).Text + "','" + (Table2.FindControl("Bxueyuan"+i.ToString()) as TextBox).Text + "','" + (Table2.FindControl("Bbanji"+i.ToString()) as TextBox).Text + "')";
            }
    这个是插入语句,提示     未将对象引用设置到对象的实例
      

  9.   


    void CreateTableRow(int index)     
    {         
    TableRow tbleRow = new TableRow();         
    TableCell tbleCell = new TableCell();           
    tbleCell.Controls.Add(new LiteralControl(Table2.Rows.Count.ToString()));         tbleRow.Cells.Add(tbleCell);           
    tbleCell = new TableCell();         
    TextBox Bxingming = new TextBox();         
    Bxingming.Style[HtmlTextWriterStyle.Width] = "88px"; 
    //这里可以给textbox的id 赋值
       Bxingming.ID = "Bm_"+  index; 
    ..............
    //其他的textbox都可以按照这种方式给id 赋值,注意要唯一性 

      

  10.   

    这个问题没有解决呀,我也遇到这样的问题,动态生成ID没问题,但取ID和ID值却没有办法实现。