473,320 Members | 2,083 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,320 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 2333
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.