I have a user control with a method to get data from a database. I'm using a tabbed main page and need to show the same info twice. Is there some way of having 2 user controls on the main page, but having the method called only once and fill the 2 different controls? The method gets data from a db and it seems like a waste to call it twice for the same thing.
public partial class control : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
public void bindcontrol(int id, string pie)
{
//get info from database and bind it to a gridview
}
}
main page
<%@ Register TagPrefix="z" TagName="zz" Src="control.ascx" %>
<div role="tabpanel" class="tab-pane" id="passport">
<z:zz ID="ctrl1" runat="server" />
</div>
<div role="tabpanel" class="tab-pane" id="passport">
<z:zz ID="ctrl2" runat="server" />
</div>
//code behind - which is what I'm trying to avoid:
ctrl1.bindSummary(id, strPIE);
ctrl2.bindSummary(id, strPIE);