自己写了个<asp:table id="Table2" runat="server" CellSpacing="1" CellPadding="0" BackColor="#cccccc" Width="780"></asp:table>然后在里面写了几个TextBox.怎样才能把TextBox里值插入到数据库呢?
谢谢大家了

解决方案 »

  1.   

    直接insert吗?但我是手写控件
      

  2.   

    TableRow tr = new TableRow();
    TableCell tc = new TableCell();
    TextBox txt2 = new TextBox();
    txt2.ID = "txtFu"+this.Table2.Rows.Count;
    tc.Controls.Add(txt2);
    tr.Cells.Add(tc);
    this.Table2.Rows.Add(tr);
    我是这样的
      

  3.   


    string ss;
    TextBox tt=new TextBox();
    tt=(TextBox)Table2.findcontrol(ID);
    ss=tt.text;
    我是这样想的
    不知道对不对。
      

  4.   

    你是程序创建的textbox么?如果是的话page_load函数里就算是postback还是要创建一次,这样才能访问到,或者你把table放到一个placeholder里也行
      

  5.   

    我现在的问题是如何才能得到文本框里的值。
    TableRow   tr   =   new   TableRow(); 
    TableCell   tc   =   new   TableCell(); 
    TextBox   txt2   =   new   TextBox(); 
    txt2.ID   =   "txtFu"+this.Table2.Rows.Count; 
    tc.Controls.Add(txt2); 
    tr.Cells.Add(tc); 
    this.Table2.Rows.Add(tr);
    手动创建的table和控件,不知道该怎么获取。我用viewstate,request呀都得到的是空值