Solved

accessing controls in listview on page_load

Posted on 2010-09-02
3
706 Views
Last Modified: 2012-05-10
Hi,

I'm having trouble using the findcontrol method to modify listview content on page_load. What i need to do is populate a listbox programmatically. I know the reason is because i can't modify a listview that hasnt been created yet.

I get the error:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

the index is -1, but there must be a way to access a nested control on page_load or without the user having to click something right?
0
Comment
Question by:OTM
[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
3 Comments
 
LVL 3

Accepted Solution

by:
JessyEzzy earned 500 total points
ID: 33606462
Try using FindControl in the DataBound event of the ListView
0
 

Author Closing Comment

by:OTM
ID: 33615685
Thanks, this pointed me in the right direction. The other reason the objects werent found was because they weren't found was because they werent actually created under the current edit mode.

See http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listview.editindex.aspx
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

724 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