Solved

DropDownList in a Repeater

Posted on 2006-07-11
4
337 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

717 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