2011-04-14 53 views
0

首先,我创建了一个动态表并添加了一些文本框。检索动态控件的值

 Dim tblRows As Integer = nos 
     Dim tblCols As Integer = 2 
     ''# Create a Table and set its properties 
     Dim tbl As Table = New Table() 
     ''# Add the table to the placeholder control 
     PlaceHolder1.Controls.Add(tbl) 
     ''# Now iterate through the table and add your controls 
     For i As Integer = 0 To tblRows - 1 
      Dim tr As TableRow = New TableRow() 
      For j As Integer = 0 To tblCols - 1 
       Dim tc As TableCell = New TableCell() 
       Dim lbl As Label = New Label() 
       lbl.Text = "Student Name" 

       If j = 0 Then 

        tc.Controls.Add(lbl) 
        ''# Add the TableCell to the TableRow 
        tr.Cells.Add(tc) 

       Else 

        Dim txtBox As TextBox = New TextBox() 
        ''#txtBox.AutoPostBack = True 
        txtBox.ID = "aa" + i.ToString() 
        ''#txtBox.ID = "TextBoxID" + (i + 1).ToString() 
        ''#txtBox(i) = New TextBox 
        ''# Add the control to the TableCell 
        tc.Controls.Add(txtBox) 
        ''# Add the TableCell to the TableRow 
        tr.Cells.Add(tc) 

       End If 

      Next j 
      ''# Add the TableRow to the Table 
      tbl.Rows.Add(tr) 
     Next i 
     Dim btn As Button = New Button() 
     btn.Text = "SUBMIT" 
     PlaceHolder1.Controls.Add(btn) 

现在点击按钮,我需要检索在各种文本框中输入的值并将其插入到数据库中。任何人都可以帮我解决这个问题吗?

回答