473,626 Members | 3,221 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Selec tedValue

Case 1

Dim tRow As New HtmlTableRow
For k = 0 to To 2
tRow.Cells.Add( New HtmlTableCell)
Next

totalRowCount = tblInsertSP.Row s.Count

tblInsertSP.Row s(totalRowCount - 1).Cells(0).Inn erText = "Aircrafts"

Dim txtAircrafts As New TextBox
tblInsertSP.Row s(totalRowCount -
1).Cells(1).Con trols.Add(txtAi rcrafts)

Case 2

....

End Select
After adding extra rows dynamically, I want to save the entered information
into the database tables, SP and SPAviationCompa ny (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.Find Control("tblIns ertSP").FindCon trol("txtAircra fts"),
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 2415
It seems VS.2003 doesn't fully support controls
dynamically created (I mean we cannot reference a
dynamically created control by FindControl(ctr lID) 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 = "txtAircraf ts"

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

Hope it's helpful to you.

Elton Wang

el********@hotm ail.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.Selec tedValue

Case 1

Dim tRow As New HtmlTableRow
For k = 0 to To 2
tRow.Cells.Add( New HtmlTableCell)
Next

totalRowCount = tblInsertSP.Row s.Count

tblInsertSP.Row s(totalRowCount - 1).Cells (0).InnerText = "Aircrafts"
Dim txtAircrafts As New TextBox
tblInsertSP.Row s(totalRowCount -
1).Cells(1).Co ntrols.Add(txtA ircrafts)

Case 2

....

End Select
After adding extra rows dynamically, I want to save the entered informationinto the database tables, SP and SPAviationCompa ny (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.Find Control("tblIns ertSP").FindCon trol ("txtAircrafts" ),TextBox).Tex t

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***@discussi ons.microsoft.c om> 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(ctr lID) 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 = "txtAircraf ts"

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

Hope it's helpful to you.

Elton Wang

el********@hotm ail.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.Selec tedValue

Case 1

Dim tRow As New HtmlTableRow
For k = 0 to To 2
tRow.Cells.Add( New HtmlTableCell)
Next

totalRowCount = tblInsertSP.Row s.Count

tblInsertSP.Row s(totalRowCount - 1).Cells

(0).InnerText = "Aircrafts"

Dim txtAircrafts As New TextBox
tblInsertSP.Row s(totalRowCount -
1).Cells(1).Co ntrols.Add(txtA ircrafts)

Case 2

....

End Select
After adding extra rows dynamically, I want to save the

entered information
into the database tables, SP and SPAviationCompa ny (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.Find Control("tblIns ertSP").FindCon trol

("txtAircrafts" ),
TextBox).Tex t

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
2173
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 Harjinder!
7
2329
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 modules/controls (eg a newsfeed, quick phonelist, login, etc.) But the controls end up too 'deep': it appears that it would be lighter/better if I could just enherit the uc_login.aspx directly off of the uc_container.aspx so that all modules have the same...
3
1759
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 could have 10 rows / controls. How do i create a server control that goes into the appropriate grid cell? Example: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
4
5874
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> (fyi: the radiobuttonlist-control is placed in a datalist.) But I get this error: '<%# DataBinder.Eval(Container.DataItem, "optionnameFR") %>' is not a valid identifier
1
6342
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 dataset to dynamically create a Html Table control. I want to display the table on another frame page (target="main") without the web form controls (i.e. the textbox, search button, and dropdown list). I just want the table displayed only on the...
0
1159
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 these controls I would like to add some javascript to the page loading my control. The problem is only - nothing happens. The code that loads my usercontrol from my ASPX-page is: tdContent.Controls.Add(Page.LoadControl(contentControl));
2
2395
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 as a layout device. Typically I would go with a std html table. With VS2005 I have a choice of a html table control or the web table control. I understand the jus of differences between the two, but I am still unsure whether using the html...
1
2404
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> <li>Dress shoes</li> <li>Tap / Ballet </li>
0
2912
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 has three rows with a slider control in each row created dynamically. The problems what I have are 1) handler image does not get displayed, I have set the handleImageUrl and have moved the handlecssclass and railcssclass into local style sheet 2)...
0
8265
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8196
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8705
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8637
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8364
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5574
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4197
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1808
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.