473,382 Members | 1,441 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,382 software developers and data experts.

Create controls dynamically: Getting an error

Hi all
Pls give me some insight as to what I should be doing.
I have a form where I have 20 text boxes and when an user submits the form I
save it to a database. When they want to retrieve it, I loop and create the
textboxes with ID and text value and then add to the form. The problem is
when trying to create the control in the code behind page I get the error
"Multiple controls with the same ID 'txtQLLink1' were found".
How do I retrieve the data and display it in the text boxes in the form?

Thanks
V
Jul 21 '05 #1
3 2339
Hi Varad,
"Multiple controls with the same ID 'txtQLLink1' were found". This means that you were not able to assign unique IDs to controls in your
page. Check whether the loop in which you are re-creating the controls, you
are also incrementing the index value for the control. This will ensure that
they get unique names like txtQLLink1, txtQLLink2, txtQLLink3 ...

If this is working fine, then you must be having some other textbox with the
same ID.

HTH,

Need any help, do post a msg back..
Happy Coding

"Varad" wrote:
Hi all
Pls give me some insight as to what I should be doing.
I have a form where I have 20 text boxes and when an user submits the form I
save it to a database. When they want to retrieve it, I loop and create the
textboxes with ID and text value and then add to the form. The problem is
when trying to create the control in the code behind page I get the error
"Multiple controls with the same ID 'txtQLLink1' were found".
How do I retrieve the data and display it in the text boxes in the form?

Thanks
V

Jul 21 '05 #2
Hi Vishnu
Thanks for responding. I have controls already named txtQlLink1, txtQLLink2
etc in the .aspx form. I created those controls by dragging and dropping them
on to the form first. Now, I'm trying to reload the page with values
retrieved from the database but doing it in a loop instead of having to do it
for each control.

This is the code that is used to set the code to the text conrols:
For Each arrValueQL As String In arrQC
qlCount = qlCount + 1
If arrValueQL <> "" Then
If (qlCount Mod 2) = 1 Then
Dim txtQLLink As New TextBox
txtQLLink.ID = "txtQLLink" & i.ToString
txtQLLink.Text = arrValueQL
Me.FindControl("Form1").Controls.Add(txtQLLink)
ElseIf (qlCount Mod 2) = 0 Then
Dim txtQLUrl As New TextBox
txtQLUrl.ID = "txtQLUrl" & i.ToString
txtQLUrl.Text = arrValueQL
Me.FindControl("Form1").Controls.Add(txtQLUrl)
i = i + 1
End If
End If
Next


"Vishnu-Chivukula" wrote:
Hi Varad,
"Multiple controls with the same ID 'txtQLLink1' were found".

This means that you were not able to assign unique IDs to controls in your
page. Check whether the loop in which you are re-creating the controls, you
are also incrementing the index value for the control. This will ensure that
they get unique names like txtQLLink1, txtQLLink2, txtQLLink3 ...

If this is working fine, then you must be having some other textbox with the
same ID.

HTH,

Need any help, do post a msg back..
Happy Coding

"Varad" wrote:
Hi all
Pls give me some insight as to what I should be doing.
I have a form where I have 20 text boxes and when an user submits the form I
save it to a database. When they want to retrieve it, I loop and create the
textboxes with ID and text value and then add to the form. The problem is
when trying to create the control in the code behind page I get the error
"Multiple controls with the same ID 'txtQLLink1' were found".
How do I retrieve the data and display it in the text boxes in the form?

Thanks
V

Jul 21 '05 #3
Hi varad!

I have not played with Vb or web development on a .net language yet... but
as far as I can see you allready have a textbox with that id.... I notice
that you are declaring new textboxes where you already have those textboxes
ids in your form. In a regular application you could access the form's
Controls property and itenerate over the allready created control... find
the controls that are textboxes and have the specific id... and just change
their properties, instead of re-declaring a whole new textbox.
I am out of my environment since i code under c# and applications... but I
just thought I would give my two cents.
"Varad" <Va***@discussions.microsoft.com> wrote in message
news:B1**********************************@microsof t.com...
Hi Vishnu
Thanks for responding. I have controls already named txtQlLink1,
txtQLLink2
etc in the .aspx form. I created those controls by dragging and dropping
them
on to the form first. Now, I'm trying to reload the page with values
retrieved from the database but doing it in a loop instead of having to do
it
for each control.

This is the code that is used to set the code to the text conrols:
For Each arrValueQL As String In arrQC
qlCount = qlCount + 1
If arrValueQL <> "" Then
If (qlCount Mod 2) = 1 Then
Dim txtQLLink As New TextBox
txtQLLink.ID = "txtQLLink" & i.ToString
txtQLLink.Text = arrValueQL
Me.FindControl("Form1").Controls.Add(txtQLLink)
ElseIf (qlCount Mod 2) = 0 Then
Dim txtQLUrl As New TextBox
txtQLUrl.ID = "txtQLUrl" & i.ToString
txtQLUrl.Text = arrValueQL
Me.FindControl("Form1").Controls.Add(txtQLUrl)
i = i + 1
End If
End If
Next


"Vishnu-Chivukula" wrote:
Hi Varad,
> "Multiple controls with the same ID 'txtQLLink1' were found".

This means that you were not able to assign unique IDs to controls in
your
page. Check whether the loop in which you are re-creating the controls,
you
are also incrementing the index value for the control. This will ensure
that
they get unique names like txtQLLink1, txtQLLink2, txtQLLink3 ...

If this is working fine, then you must be having some other textbox with
the
same ID.

HTH,

Need any help, do post a msg back..
Happy Coding

"Varad" wrote:
> Hi all
> Pls give me some insight as to what I should be doing.
> I have a form where I have 20 text boxes and when an user submits the
> form I
> save it to a database. When they want to retrieve it, I loop and create
> the
> textboxes with ID and text value and then add to the form. The problem
> is
> when trying to create the control in the code behind page I get the
> error
> "Multiple controls with the same ID 'txtQLLink1' were found".
> How do I retrieve the data and display it in the text boxes in the
> form?
>
> Thanks
> V

Jul 21 '05 #4

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

Similar topics

7
by: Bil Muh | last post by:
Esteemede Developers, I would like to Thank All of You in advance for your sincere guidances. I am developing a software using Visual C++ .NET Standard Edition with Windows Form (.NET)...
2
by: Patrick Marti | last post by:
Hi together I wish to create an object at runtime in the web. I get many good tips for how to do before two days by using the same Subject. So I got also the following link wich is showing...
3
by: Kiyomi | last post by:
Hello, I create a Table1 dynamically at run time, and at the same time, I would like to create LinkButton controls, also dynamically, and insert them into each line in my Table1. I would...
7
by: Tim T | last post by:
Hi, I have the need to use dynamically loaded user controls in a webform page. I have the controls loading dynamically, and that part works fine. this is the code used in a webform to dynamically...
0
by: Johnny Fugazzi | last post by:
Good morning, Background: I am working on a web that will display information about companies and contacts. I would like to have a details page that displays some basic details about the...
4
by: z f | last post by:
hi, tough one? for me it is currently. i have a user control that contains other controls like text boxes. in the client i need to dynamically add the user control using DHTML. i achive this...
1
by: keithb | last post by:
I have found that I must re-create dynamically added controls on every postback in order to find and access them programatically. The controls I am working with are inside a GridView control. When...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.