Solved

DropDownList in a Repeater

Posted on 2006-07-11
4
324 Views
Last Modified: 2008-02-26
Hello All

I have a repeater with a dropdown list.("ddlOwner")

I am trying to access the dropdown on the Sub Page_Load with this
rptEditProject.Items(0).FindControl("ddlOwner")

I can find it if it is in a Sub other than the Sub Page_Load.

Is there something I have to change to access it on the page loading?

Dim ddlOwner As DropDownList = rptEditProject.Items(0).FindControl("ddlOwner")

gives the the following error:
"Index was out of range. Must be a non negative and less than the size of the collection"

many thanks

Don
0
Comment
Question by:donaldcroswell
4 Comments
 
LVL 27

Expert Comment

by:Sammy
ID: 17079545
try this
Dim ddlOwner As  DropDownList = CType(Me.rptEditProject.Items(0).FindControl("ddlOwner"), DropDownList)

HTH
0
 
LVL 1

Accepted Solution

by:
DefaultUser earned 500 total points
ID: 17079569
If your repeator is being bounded, you need to rebind it before you can access the Items collection. Now if you do the rebinding in the PageLoad the viewstate will only be restored after the PageLoad event and hence all the changes made by the user to the drop down won't be available, so try rebinding the repeater in a method and call that method from the page_init. This should solve the problem.

DU
0
 
LVL 5

Expert Comment

by:Darth_helge
ID: 17079710
"Now if you do the rebinding in the PageLoad the viewstate will only be restored after the PageLoad event"....

One question here DefaultUser...
doesn't the LoadViewState fire before the Page_Load?
or am i terribly wrong?
0
 

Author Comment

by:donaldcroswell
ID: 17086576
Thanks Guys

I added the following code before to bind the data and it worked.

rptEditProject.DataBind()

I really appreciate the help!

Don
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question