Click here to Skip to main content
13,199,318 members (63,416 online)
Rate this:
Please Sign up or sign in to vote.

I'm creating a user control and was wondering about something. How would I be able to set the user control to have a datasource property like a listview or repeater.

Right now I have a property that I need populated with a collection that already exists as an object data source, I want to use that object data source again and set it in the user control instead of recalling the select method a second time. How would I go about doing so?

(Figure if I could just set a datasource of the collection in the user control like a listview then I would be set but if there is another way I'm open to suggestions. The user control's datasource property should only set another property inside the user control to the collection of the datasource)(Also if this doesn't make any sence ask me to re-explain sorry)
Posted 19-Sep-12 5:30am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Well, you have a DataSource property in your user control, in the set part of it you bind the value to the internal gridview or datalist you have in your user control, this should be straight forward, you don't recall the query again in within your user control.

User Control code behind
public object DataSource
    this.grdBills.DataSource =value;

Of course this is an example.
MJ_ 2-Oct-12 15:25pm
Yeah after thinking about it I figured to just do that. Was just looking at it sideways I guess :/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171020.1 | Last Updated 24 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100