Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hey,
 
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 6:30am
MJ_263

1 solution

Rate this: bad
good
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
{
  set
  { 
    this.grdBills.DataSource =value;
  }
}
 
Of course this is an example.
  Permalink  
Comments
MJ_ at 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
0 Maciej Los 290
1 OriginalGriff 275
2 Sergey Alexandrovich Kryukov 195
3 BillWoodruff 140
4 ProgramFOX 140
0 OriginalGriff 6,524
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,218
3 Manas Bhardwaj 4,657
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 24 Sep 2012
Copyright © CodeProject, 1999-2014
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