Solved

accessing controls in listview on page_load

Posted on 2010-09-02
3
695 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
3 Comments
 
LVL 22

Expert Comment

by:plusone3055
ID: 33591146
0
 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now