So i’ve got a user control called TagFilter which has 2 repeaters.
The control will be added to a page N times, with every repeater bound to a different data table.
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TagFilter.ascx.cs" Inherits="Hite.Web.Controls.TagFilter" %>
<div class="tagDiv">
<h3>
<span style="">Results By :</span>
<asp:Repeater ID="rptUsed" runat="server">
<ItemTemplate>
<span class="UsedTags">
<asp:ImageButton ID="ImageButton1" runat="server" OnCommand="UsedPops_Remove" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "tagid") %>'
ImageUrl="~/Images/errorIcon.png" />
<a href="#">
<%# DataBinder.Eval(Container.DataItem, "tagname") %></a> </span>
</ItemTemplate>
</asp:Repeater>
</h3>
<asp:Repeater ID="rptUnused" runat="server">
<ItemTemplate>
<b style="padding-left: 5px; padding-right: 5px;">
<asp:LinkButton ID="LinkButton1" runat="server" OnCommand="lbPop_Command" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "tagid") %>'><%# DataBinder.Eval(Container.DataItem, "tagname") %>
</asp:LinkButton></b>
</ItemTemplate>
</asp:Repeater>
<br />
</div>
public partial class TagFilter : System.Web.UI.UserControl
{
public DataTable UsedDT { get; set; }
public DataTable UnusedDT { get; set; }
public SearchParameters searchParams { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
rptUsed.DataSource = UsedDT;
rptUsed.DataBind();
rptUnused.DataSource = UnusedDT;
rptUnused.DataBind();
}
I loop through with a dataset that has multiple data tables and try to create the user controls
TagFilter tf = (TagFilter)Page.LoadControl("/Controls/TagFilter.ascx");
tf.UnusedDT = ds.Tables[3];
tf.UsedDT = ds.Tables[4];
tagdiv.Controls.Add(tf);
When i step through the code in the debugger, the data table has rows when it’s assigned to the control, but has no rows on page_Load.
Can someone please help me find my error? Is it a page lifecycle issue?
You should create a method in the usercontrol.
and then call