B
buran
Dear ASP.NET Programmers,
I have a HTML table (running as server control with the control ID:
tblInsertSP). The table has 16 rows with textboxes. Depending on the value
of the ddlSPType, which is a dropdownlist control on the page, I add
dynamically extra rows to the table. For instance, if the ddlSPType selected
item is Aviation Company, an extra row containing a cell with the textbox
control txtAircrafts is added to the HTML table tblInsertSP (which now has
17 controls). I use the following code:
Dim k, totalRowCount as Int16
Select Case ddlSPType.SelectedValue
Case 1
Dim tRow As New HtmlTableRow
For k = 0 to To 2
tRow.Cells.Add(New HtmlTableCell)
Next
totalRowCount = tblInsertSP.Rows.Count
tblInsertSP.Rows(totalRowCount - 1).Cells(0).InnerText = "Aircrafts"
Dim txtAircrafts As New TextBox
tblInsertSP.Rows(totalRowCount -
1).Cells(1).Controls.Add(txtAircrafts)
Case 2
....
End Select
After adding extra rows dynamically, I want to save the entered information
into the database tables, SP and SPAviationCompany (the latter is used for
specific data of the SP, namely Aircrafts). I have to reach the txtAircrafts
control in the dynamically added row. I tried it with the following code but
it did not work:
Dim str As String
str = CType(Page.FindControl("tblInsertSP").FindControl("txtAircrafts"),
TextBox).Text
I receive an error stating that there's no such an object. How can I reach
this object? Thanks in advance.
Burak
I have a HTML table (running as server control with the control ID:
tblInsertSP). The table has 16 rows with textboxes. Depending on the value
of the ddlSPType, which is a dropdownlist control on the page, I add
dynamically extra rows to the table. For instance, if the ddlSPType selected
item is Aviation Company, an extra row containing a cell with the textbox
control txtAircrafts is added to the HTML table tblInsertSP (which now has
17 controls). I use the following code:
Dim k, totalRowCount as Int16
Select Case ddlSPType.SelectedValue
Case 1
Dim tRow As New HtmlTableRow
For k = 0 to To 2
tRow.Cells.Add(New HtmlTableCell)
Next
totalRowCount = tblInsertSP.Rows.Count
tblInsertSP.Rows(totalRowCount - 1).Cells(0).InnerText = "Aircrafts"
Dim txtAircrafts As New TextBox
tblInsertSP.Rows(totalRowCount -
1).Cells(1).Controls.Add(txtAircrafts)
Case 2
....
End Select
After adding extra rows dynamically, I want to save the entered information
into the database tables, SP and SPAviationCompany (the latter is used for
specific data of the SP, namely Aircrafts). I have to reach the txtAircrafts
control in the dynamically added row. I tried it with the following code but
it did not work:
Dim str As String
str = CType(Page.FindControl("tblInsertSP").FindControl("txtAircrafts"),
TextBox).Text
I receive an error stating that there's no such an object. How can I reach
this object? Thanks in advance.
Burak