17. July 2014 02:48
/
Jeff
/
/
Comments (0)

REFERENCE:
- Kiran Patil: http://sitecorebasics.wordpress.com/2014/04/20/sitecore-cms-version-history/
- John West : http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2011/05/Sitecore-ASPNET-CMS-Version-History.aspx
- Kim Hornung : https://www.blogger.com/feeds/36416442/posts/default
e2617317-cdd0-41d5-adcc-9238a1f59399|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
14. January 2014 10:01
/
Administrator
/
/
Comments (0)
Data binding doesn't work inside the LayoutTempate of ListView. The workaround is to utilize the LayoutCreated event to do find-and-assign:
Markup:
<asp:ListView runat="server" OnLayoutCreated="SelectedFiedls_OnLayoutCreated">
<LayoutTemplate>
<asp:Literal runat="server" ID="SeletectedFieldsTotal" /> Criteria selected for comparison:</h5>
<asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
</LayoutTemplate>
<ItemTemplate>
...
</ItemTemplate>
</asp:ListView>
Code-behind:
protected void SelectedFiedls_OnLayoutCreated(object sender, EventArgs e)
{
var selectedFieldsTotal = ((ListView)sender).FindControl("SeletectedFieldsTotal") as Literal;
selectedFieldsTotal.Text = SelectedFields.Count().ToString();
}
------------------------------------------------------------------------------------------------------------------------------------------------------------
updated: 2014-01-17 11:49 AM
The method above has issues with ViewState, as the LayoutCreated event is raised when the layout template is created in the ListView control. Obvious, it's too early for ViesState.(see
ASP.NET Page LifeCycle Overview)
If using my favorite ControlDataBind event handler:
protected void ControlDataBind(object sender, EventArgs e)
{
((Control)sender).DataBind();
}
This work can be done like:
<asp:ListView runat="server" OnLayoutCreated="SelectedFiedls_OnLayoutCreated">
<LayoutTemplate>
<asp:PlaceHolder runat="server" OnLoad="ControlDataBind">
<h5><%# SelectedFields.Count() %> Criteria selected for comparison:</h5>
</asp:PlaceHolder>
</LayoutTemplate>
<ItemTemplate>
...
</ItemTemplate>
</asp:ListView>
Happy coding!!!
7ff11357-fa54-4ae6-83f7-e22b4c1de817|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04