473,586 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding textboxes dynamically

Okay, here's my problem:

I need to populate different fields in an HTML table with TextBoxes. For
example, if I had 3 columns "Name", "Address", and "City"; I need to have a
TextBox in all of the Address fields. This is basically the code that I used.

<script language="VB" runat="server">
Sub Page_Load(Sende r As Object, E As EventArgs)
Label1.Text &= "<td align=left><inp ut type=""text"" id=""txt"
& _
Database.ReadFi eld("ID") & _
""" runat=server value=""" & _
Database.ReadFi eld("Address") & """></td>"
End Sub

Sub Update_Click(Se nder As Object, E As EventArgs)
Dim dba As DatabaseDLL = New DatabaseDLL
dba.LoadDB_SQL( Server.MapPath( "address.md b"), False, sql)

Do While Not dba.EOF
strRead = Request.Form("t xt" & dba.ReadField(" ID"))
If strRead <> "" Then
dba.EditField(" JobCost", strRead)
dba.Update()
End If

dba.MoveNext()
Loop

dba.CloseDB()
End Sub
</script>

<form runat="server">

<asp:label id="Label1" runat="server">
Edit Subtotals:<br>< br>
<a href="view_all_ estimate.aspx"> Back to Standard View</a><br><br>
</asp:label>

<input type="submit" runat="server" id="cmdSubmit"
onServerClick=" Update_Click" value="Update Material Costs">
</form>
But when I press Submit, it obviously does not pick up those TextBoxes that
I added at runtime. How am I supposed to do this?
Jun 2 '06 #1
4 1395
So you're creating a table using the text of a Label object? I don't think
that's supported...

Look at using Controls.Add.Li teralControl. You should add the table to your
form this way, or even create a table object first and add that.

Dynamically added controls are a PIA however--you have to recreate them on
postback or ASP.Net won't see them. This can get confusing/complicated quickly.

"Alex Denton" <Alex De****@discussi ons.microsoft.c om> wrote in message
news:02******** *************** ***********@mic rosoft.com...
Okay, here's my problem:

I need to populate different fields in an HTML table with TextBoxes. For
example, if I had 3 columns "Name", "Address", and "City"; I need to have a
TextBox in all of the Address fields. This is basically the code that I used.

<script language="VB" runat="server">
Sub Page_Load(Sende r As Object, E As EventArgs)
Label1.Text &= "<td align=left><inp ut type=""text"" id=""txt"
& _
Database.ReadFi eld("ID") & _
""" runat=server value=""" & _
Database.ReadFi eld("Address") & """></td>"
End Sub

Sub Update_Click(Se nder As Object, E As EventArgs)
Dim dba As DatabaseDLL = New DatabaseDLL
dba.LoadDB_SQL( Server.MapPath( "address.md b"), False, sql)

Do While Not dba.EOF
strRead = Request.Form("t xt" & dba.ReadField(" ID"))
If strRead <> "" Then
dba.EditField(" JobCost", strRead)
dba.Update()
End If

dba.MoveNext()
Loop

dba.CloseDB()
End Sub
</script>

<form runat="server">

<asp:label id="Label1" runat="server">
Edit Subtotals:<br>< br>
<a href="view_all_ estimate.aspx"> Back to Standard View</a><br><br>
</asp:label>

<input type="submit" runat="server" id="cmdSubmit"
onServerClick=" Update_Click" value="Update Material Costs">
</form>
But when I press Submit, it obviously does not pick up those TextBoxes that
I added at runtime. How am I supposed to do this?

Jun 2 '06 #2

Mike Lowery wrote:
So you're creating a table using the text of a Label object? I don't think
that's supported...

Heck yeah its supported. Its a horrible way of doing things, but I've
built an entire navigable calendar inside the text property of a label.

But yes, literals are the way to go here.

Tex

Jun 2 '06 #3
Can you explain to me how I would recreate them on postback while maintaining
their values?

"rg******@gmail .com" wrote:

Mike Lowery wrote:
So you're creating a table using the text of a Label object? I don't think
that's supported...

Heck yeah its supported. Its a horrible way of doing things, but I've
built an entire navigable calendar inside the text property of a label.

But yes, literals are the way to go here.

Tex

Jun 2 '06 #4
I should have said "officially supported" in my earlier post.

See this article:
http://aspnet.4guysfromrolla.com/articles/092904-1.aspx

"Alex Denton" <Alex De****@discussi ons.microsoft.c om> wrote in message
news:63******** *************** ***********@mic rosoft.com...
Can you explain to me how I would recreate them on postback while maintaining
their values?

"rg******@gmail .com" wrote:

Mike Lowery wrote:
> So you're creating a table using the text of a Label object? I don't think
> that's supported...
>

Heck yeah its supported. Its a horrible way of doing things, but I've
built an entire navigable calendar inside the text property of a label.

But yes, literals are the way to go here.

Tex

Jun 5 '06 #5

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

Similar topics

2
10081
by: Briand | last post by:
In my previous posting I failed miserably, to give enough information to get my difficulty apparent. So to start again. I want to create textboxes dynamically in VB.NET. This is not a web application that I'm trying to build. I should add that i am a very new user to VB.NET and as such am very ignorant so please excuse this. Many...
15
12360
by: crjunk | last post by:
I have 4 TextBoxes on my form that I'm trying to add together to get a grand total. Here is the code I'm using: <SCRIPT LANGUAGE="JavaScript"> <!-- Beginning of JavaScript - function calcTotalPub() { var tempFed = +document.Form1.value; var tempState = +document.Form1.value;
1
4690
by: Shayer | last post by:
Hello I want to add some dynamic control in the win form when i press a button I write the following line of code. But the problem is instead of displaying 10 textbox it display 9 textboxes.But it display another textbox when i hit the button again. Can any one pls give me any solution of it. Anyother alternative solution is appriciable as...
6
1280
by: Dany P. Wu | last post by:
Hi everyone, I created a page which contains a two-column table. The first column has a bunch of labels, and the second a bunch of textboxes. Here's the code: ====================================================== Protected WithEvents Container As System.Web.UI.WebControls.PlaceHolder Private Sub ConstructEditTable()...
0
1867
by: Sileesh | last post by:
Hi I have html table and a Button in an Aspx page. I am adding one row with some textboxes to Html table each time i click on the Button thru Javascript. Now problem is when when i try to collect the data in the Textboxes which i added dynamically from server side, i am not able to do . Alos i tried to bedug, the total no of rows in Html...
5
1039
by: Will Lastname | last post by:
I'm working on administration panel that will ultimately allow the client to edit products in a collection. Each ProjectList can have multiple products within it. I was asked to create something that will allow them to edit the products within that list. I was thinking of writing using a DataReader and spitting the values out into textboxes....
5
1695
by: BLACKDOG157 | last post by:
I've made a form with a variable number of textboxes. The user fills them out, and then I need to pick up the values he has filled in. The number of textboxes vary depending on a value that the user filled in in another page. But suppose there were 3 values. In that case, I know the names of the fields, they are MyTextBox1 MyTextbox2...
1
8404
by: Sirisha | last post by:
Hi, I want javascript for displaying multiple textboxes dynamically. ADD-this is button. if i click button first time it will display 1 textbox and if i click 2nd time it will display another textbox,if i click that button once again display another textbox.if i click 10 times it will display 10 textboxes. so i want code for displaying...
0
1501
by: rvdnieuwenhuizen | last post by:
Hi, The problem I cannot seem to solve: I have a page with a button control. In the On_Click eventhandler I dynamically add one TextBox each time the button is clicked. I add the textboxes to an update panel. I store the ID for the generated textboxes in the Viewstate, which I use in the Panels' INIT eventhandler to go ahead and...
0
7912
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...
0
8338
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...
1
7959
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...
1
5710
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...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.