I created a user control (.ascx) that contains a paging-user-control, a repeater and some other controls.
I want to use the property DataSourceID. How should I get the data from the datasource and when?
What is the recommended way?
I did it this way:
- Create a method to get the data by reflection, like:
private void PerformSelect()
Control control = Page.FindControl(this.DataSourceID);
if (control == null)
control = Parent.FindControl(this.DataSourceID);
MethodInfo method = control.GetType().GetMethod("Select");
IEnumerable data = (IEnumerable)method.Invoke(control, new object);
this.DataSource = data;
- Call this method
In PageLoad when no postback
Changing the current page (paging-user-control)
Changing the current tab (tab-user-control)
Switching Visibility to true
I think that way is not the optimum, is there any better way?
Do you have any suggestions or links?
Thanks for your help, Andreas
View Complete Post