code_junkie

Creating a UserControl Programmaticly within a repeater?

Nov 10th, 2011
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. void rptrTaskList_ItemDataBound(object sender, RepeaterItemEventArgs e)
  2. {
  3. CCTask task = (CCTask)e.Item.DataItem;
  4.  
  5. if (task is ExecTask)
  6. {
  7. ExecTaskControl foo = new ExecTaskControl();
  8. e.Item.Controls.Add(foo);
  9. }
  10. }
  11.  
  12. ExecTaskControl foo = (ExecTaskControl)LoadControl("tasks\ExecTaskControl.ascx");
  13.  
  14. var myPage = new System.Web.UI.Page();
  15. var myControl = (Controls.MemberRating)myPage.LoadControl("~/Controls/MemberRating.ascx");
Add Comment
Please, Sign In to add comment