473,385 Members | 2,014 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,385 software developers and data experts.

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(Sender As Object, E As EventArgs)
Label1.Text &= "<td align=left><input type=""text"" id=""txt"
& _
Database.ReadField("ID") & _
""" runat=server value=""" & _
Database.ReadField("Address") & """></td>"
End Sub

Sub Update_Click(Sender As Object, E As EventArgs)
Dim dba As DatabaseDLL = New DatabaseDLL
dba.LoadDB_SQL(Server.MapPath("address.mdb"), False, sql)

Do While Not dba.EOF
strRead = Request.Form("txt" & 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 1387
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.LiteralControl. 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****@discussions.microsoft.com> wrote in message
news:02**********************************@microsof t.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(Sender As Object, E As EventArgs)
Label1.Text &= "<td align=left><input type=""text"" id=""txt"
& _
Database.ReadField("ID") & _
""" runat=server value=""" & _
Database.ReadField("Address") & """></td>"
End Sub

Sub Update_Click(Sender As Object, E As EventArgs)
Dim dba As DatabaseDLL = New DatabaseDLL
dba.LoadDB_SQL(Server.MapPath("address.mdb"), False, sql)

Do While Not dba.EOF
strRead = Request.Form("txt" & 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****@discussions.microsoft.com> wrote in message
news:63**********************************@microsof t.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
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...
15
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...
1
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...
6
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: ...
0
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...
5
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...
5
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...
1
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...
0
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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,...
0
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...

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.