Geeks With Blogs

News My Blog has been MOVED to
Michael Freidgeim's OLD Blog My Blog has been MOVED to

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" >
                                <asp:datagrid id=Datagrid1 runat="server"  DataSource=''
<%# GetDetails(DataBinder.Eval(Container.DataItem, "CategoryID")) %>'
                                </< FONT>asp:datagrid>
                </< FONT>
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.


Posted on Saturday, September 16, 2006 12:41 PM ASP.NET | Back to top

Comments on this post: Nested Data Bound UserControl

# re: Nested Data Bound UserControl
Requesting Gravatar...
Related articles:
Using Web User Controls in Repeaters and DataList
Left by Michael Freidgeim on Dec 02, 2007 10:39 PM

Your comment:
 (will show your gravatar)

Copyright © Michael Freidgeim | Powered by: