473,385 Members | 1,622 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.

populate multiple dropdownlist

Hi,

I am try to populate a number of dropdownlist with the same item,

for i = 1 to 5
dd = me.controls("dd" + Cstr(i))

itm = new listiem
itm.text ="abc"
itm.value ="aaa"

dd.add(itm)

next i
But I am getting the following error
"Conversion from string "dd1" to type 'Integer' is not valid"
when it hits this line.
dd = me.controls("dd" + Cstr(i))

Please help. I just wonder how I can refer to a control to a page
dynamically

Thanks in advance.

Aug 27 '07 #1
3 1890
Hi there,

Use FindControl method of the containing control. For instance, if dynamic
controls are added into a panel try:

dd = CType(myPanelId.FindControl("dd" + CStr(i)), DropDownList)

Should help.

P.S. Remember dynamic controls have to be recreated on every postback.
--
Milosz
"sw**********@yahoo.com" wrote:
Hi,

I am try to populate a number of dropdownlist with the same item,

for i = 1 to 5
dd = me.controls("dd" + Cstr(i))

itm = new listiem
itm.text ="abc"
itm.value ="aaa"

dd.add(itm)

next i
But I am getting the following error
"Conversion from string "dd1" to type 'Integer' is not valid"
when it hits this line.
dd = me.controls("dd" + Cstr(i))

Please help. I just wonder how I can refer to a control to a page
dynamically

Thanks in advance.

Aug 27 '07 #2
Thanks for the advice, actually, all controls exit already, it is just
a matter that I need to make them visible. I tried to your suggested
syntax, but it doesn't work, it just retrun nothing.

Please advice and thanks in advance.
On Aug 27, 4:28 pm, Milosz Skalecki [MCAD] <mily...@DONTLIKESPAMwp.pl>
wrote:
Hi there,

Use FindControl method of the containing control. For instance, if dynamiccontrolsare added into a panel try:

dd = CType(myPanelId.FindControl("dd" + CStr(i)), DropDownList)

Should help.

P.S. Remember dynamiccontrolshave to be recreated on every postback.
--
Milosz

"sweetpota...@yahoo.com" wrote:
Hi,
I am try to populate a number of dropdownlist with the same item,
for i = 1 to 5
dd = me.controls("dd" + Cstr(i))
itm = new listiem
itm.text ="abc"
itm.value ="aaa"
dd.add(itm)
next i
But I am getting the following error
"Conversion from string "dd1" to type 'Integer' is not valid"
when it hits this line.
dd = me.controls("dd" + Cstr(i))
Please help. I just wonder how I can refer to a control to a page
dynamically
Thanks in advance.- Hide quoted text -

- Show quoted text -

Aug 28 '07 #3
Good evening,

Could you please paste entire code so we could have a look what exactly have
been done.

Regards
--
Milosz
"sw**********@yahoo.com" wrote:
Thanks for the advice, actually, all controls exit already, it is just
a matter that I need to make them visible. I tried to your suggested
syntax, but it doesn't work, it just retrun nothing.

Please advice and thanks in advance.
On Aug 27, 4:28 pm, Milosz Skalecki [MCAD] <mily...@DONTLIKESPAMwp.pl>
wrote:
Hi there,

Use FindControl method of the containing control. For instance, if dynamiccontrolsare added into a panel try:

dd = CType(myPanelId.FindControl("dd" + CStr(i)), DropDownList)

Should help.

P.S. Remember dynamiccontrolshave to be recreated on every postback.
--
Milosz

"sweetpota...@yahoo.com" wrote:
Hi,
I am try to populate a number of dropdownlist with the same item,
for i = 1 to 5
dd = me.controls("dd" + Cstr(i))
itm = new listiem
itm.text ="abc"
itm.value ="aaa"
dd.add(itm)
next i
But I am getting the following error
"Conversion from string "dd1" to type 'Integer' is not valid"
when it hits this line.
dd = me.controls("dd" + Cstr(i))
Please help. I just wonder how I can refer to a control to a page
dynamically
Thanks in advance.- Hide quoted text -
- Show quoted text -


Aug 28 '07 #4

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

Similar topics

2
by: .Net Newbie | last post by:
Hello, I am currently coding my ASP.Net pages in c# and have run into a question concerning Emails. I have four objects on a page (six including 2 buttons). The first is a subject line...
5
by: Lie | last post by:
Hi all, I have problem in getting selectedindex of multiple listbox selection in a datagrid. I have a listbox with multiple selection mode inside datagrid. In Edit mode, I need to get back all...
2
by: Rui Macdonald | last post by:
What is wrong with this code to populate a DropDownList? Can somebody Help me? Tnx RMac ===================================================================================== WebForm.aspx.vb
1
by: mr2_93 | last post by:
Hi All, I am new to ASP.NET and I am looking for help with the dropdownlist data control. I wonder if someone could show me how to past the SelectedValue of a data-bind dropdownlist to...
10
by: ads | last post by:
hi, after binding the dropdownlist to a datasource, ive experience this error "Cannot have multiple items selected in a dropdownlist" after using the code:...
2
by: bobbyc13 | last post by:
I am new to vb.net and am getting frustrated and cannot find a post on the subject. I have a usercontrol (.ascx) with a dropdownlist. on the selectedindexchanged event of the codebeside of the...
6
by: peerraghu | last post by:
hi i am developing website which is a online shoping i want to populate two dropdownlist, in which the first dropdownlist should place the list of a paticular product and the next dropdownlist...
2
by: Aswanth | last post by:
Hi.. I'm using Asp.Net with C#.... I'm having One Dropdownlist control(Users_Details_DDL) in Default.aspx Page... i'm having one Stored Procedure (Get_User_Email) which will display the Data...
5
by: =?Utf-8?B?U2F0aXNo?= | last post by:
C#, ASP.NET Q: Have a formview, with a dropdownlist which is bound to a column. This dropdownlist has a datasource of DataSet type. Now my objective is, on Selection Changed of this DropdownList,...
1
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: 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...
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: 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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.