I needed to have ASP.NET report with DataRepeater and nested data bound user control.The similar approach is used in ASP.NET Reports Starter Kit with datagrid nested in datalist itemtemplate.
<asp:datalist id="CategoriesList" runat="server" > <itemtemplate> <asp:datagrid id=Datagrid1 runat="server" DataSource=''<%# GetDetails(DataBinder.Eval(Container.DataItem, "CategoryID")) %>' </< FONT>asp:datagrid> </< FONT>itemtemplate> <headerstyle cssclass="ReportTitle"></< FONT>headerstyle> </< FONT>asp:datalist> So my markup should be like this:
<%@ Register Src="MyUserControl.ascx" TagName="MyUserControl" TagPrefix="uc1" %>
<asp:Repeater ID="Repeater1" runat="server">
<uc1:MyUserControl DataSource=<%# GetDetails(DataBinder.Eval(Container.DataItem,"PatronId")) %>
ReportId= <%# ReportID %> id="patronNotice" runat="server" >
I’ve created DataSource property and on DataBinding event used it to populate my UserControl data. But it didn’t work. DataBinding event occurred earlier than DataSource was set from DataBinding expression and DataSource=Nothing.
I’ve read carefully the DataBinding documentation and understood that DataBind can be called more than once during the same request and it is important to re-do binding if DataSource property has been changed.So I had to implement Data Bound User Control class to resolve the issue.
© Michael Freidgeim
Theme by PiyoDesign. Valid XHTML & CSS.