473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to reach a control in a dynamically extended HTML Table

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


Nov 19 '05 #1
2 2398
It seems VS.2003 doesn't fully support controls
dynamically created (I mean we cannot reference a
dynamically created control by FindControl(ctrlID) method.
Anyway, you can get still it by Request object.

Firstly you need assign ID to your TextBox like
Dim txtAircrafts As New TextBox
txtAircrafts.ID = "txtAircrafts"

Then using following code retrieve value in the text box
Dim str As String = Request.Form.Get("txtAircrafts")

Hope it's helpful to you.

Elton Wang

el********@hotmail.com

-----Original Message-----
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 valueof the ddlSPType, which is a dropdownlist control on the page, I adddynamically extra rows to the table. For instance, if the ddlSPType selecteditem is Aviation Company, an extra row containing a cell with the textboxcontrol txtAircrafts is added to the HTML table tblInsertSP (which now has17 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 informationinto the database tables, SP and SPAviationCompany (the latter is used forspecific data of the SP, namely Aircrafts). I have to reach the txtAircraftscontrol in the dynamically added row. I tried it with the following code butit 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 reachthis object? Thanks in advance.

Burak


.

Nov 19 '05 #2
Thank you Mr. Wang, this solved my problem :)
"Elton Wang" <el***@discussions.microsoft.com> wrote in message
news:0f****************************@phx.gbl...
It seems VS.2003 doesn't fully support controls
dynamically created (I mean we cannot reference a
dynamically created control by FindControl(ctrlID) method.
Anyway, you can get still it by Request object.

Firstly you need assign ID to your TextBox like
Dim txtAircrafts As New TextBox
txtAircrafts.ID = "txtAircrafts"

Then using following code retrieve value in the text box
Dim str As String = Request.Form.Get("txtAircrafts")

Hope it's helpful to you.

Elton Wang

el********@hotmail.com

-----Original Message-----
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


.

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: bobdedogh | last post by:
can anyone add live hyperlinks to the sortable table made by the code supplied by Machi, or know of a simple alternative bob Machi wrote Mar 10 1999, 8:00 am >>>>>>>>>>>>>> .... Hello...
7
by: Sky | last post by:
What I have currently: I have a user control called mod_container.aspx that is basically two divs -- the top a toolbar, that expands/collapse the second div which can contain other...
3
by: Chris Thunell | last post by:
I have an aspx web form with a table that i'm sending via response.write... in one of the cells i would like to put a dynamically created server control. The amount of rows is variable... so i...
4
by: nicholas | last post by:
I tried to set the ID of a radiobuttonlist dynamicaly like this: <asp:RadioButtonList id="<%# DataBinder.Eval(Container.DataItem, "optionnameFR") %>" runat="server" ></asp:RadioButtonList> ...
1
by: Al Wilkerson | last post by:
Hey, I have a Web Form with a drop down list, textbox, and search button. When click the search button an SQL server database is queried fordata. Once I have the data in a dataset I use the...
0
by: Jesper Lund Stocholm | last post by:
I have problems with sending javascript to the client from a dynamically loaded usercontrol. I have a single page that dynamically loads controls into a table cell in a HTML-table. For one of...
2
by: Geary | last post by:
I am porting my first traditional app to a web-based app using VS2005 and ASP.NET 2.0. I have a page that will replace a data entry form. To have complete control of layout, I want to use a table...
1
by: n00b0101 | last post by:
Is there a way to use javascript to change/update a class depending upon a click? For example: INITIAL HTML <h1 class="superhead">TODDLER</h1> <ul class="extended"> <li>Sneakers</li>...
0
by: sanrek | last post by:
Hi Folks, Slider control is driving me nuts, below is the code from my test page's page load event, nothing great about code, I have a place holder control into which I am adding a table which...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.