Solved

accessing controls in listview on page_load

Posted on 2010-09-02
3
703 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 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