temperory temperory
Top achievements
Rank 1
temperory temperory
asked on 02 Jan 2011, 03:32 PM
Hi Dear
When I use LayoutTemplate in design time it`s work correctly but in runtime when i use "Page.LoadTemplate" method for loading template when DataBind() fired it thrown exception :
"
Best Regards.
When I use LayoutTemplate in design time it`s work correctly but in runtime when i use "Page.LoadTemplate" method for loading template when DataBind() fired it thrown exception :
"
The RadListView control does not have an item placeholder specified.
"RadListView1.PageSize = (
int
)contentList.PageSize;
RadListView1.DataSource = contents;
RadListView1.LayoutTemplate = Page.LoadTemplate(contentList.LayoutTemplate);
RadListView1.ItemTemplate = Page.LoadTemplate(contentList.ItemTemplate);
RadListView1.VirtualItemCount = totlaCount;
RadListView1.DataBind();
Best Regards.
4 Answers, 1 is accepted
0
Hello,
Bellow links demonstrates how to create RadListView programmatically:
http://demos.telerik.com/aspnet-ajax/listview/examples/definingstructure/programmaticdefinition/defaultcs.aspx
http://www.telerik.com/help/aspnet-ajax/listview-programmatic-definition.html
All the best,
Nikolay
the Telerik team
Bellow links demonstrates how to create RadListView programmatically:
http://demos.telerik.com/aspnet-ajax/listview/examples/definingstructure/programmaticdefinition/defaultcs.aspx
http://www.telerik.com/help/aspnet-ajax/listview-programmatic-definition.html
All the best,
Nikolay
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
temperory temperory
Top achievements
Rank 1
answered on 04 Jan 2011, 09:58 AM
Hi
Tanks for your answer.I see all examples and help but there is no sample that use Page.LoadTemplae method.
Below you can see my sample that thrown exception :
Default.aspx
Default.aspx.cs
ItemTemplate.ascx
LayoutTemplate.ascx
Best Regards.
Tanks for your answer.I see all examples and help but there is no sample that use Page.LoadTemplae method.
Below you can see my sample that thrown exception :
Server Error in '/' Application.
--------------------------------------------------------------------------------
The RadListView control does not have an item placeholder specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The RadListView control does not have an item placeholder specified.
Source Error:
Line 20: RadListView1.LayoutTemplate = Page.LoadTemplate("LayoutTemplate.ascx");
Line 21: RadListView1.ItemTemplate = Page.LoadTemplate("ItemTemplate.ascx");
Line 22: RadListView1.DataBind();
Line 23: }
Line 24:
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="RadListView.Default" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
</
telerik:RadScriptManager
>
<
telerik:RadListView
ID
=
"RadListView1"
runat
=
"server"
>
</
telerik:RadListView
>
</
div
>
</
form
>
</
body
>
</
html
>
Default.aspx.cs
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Page_PreInit(object sender, EventArgs e)
{
RadListView1.DataSource = GetStudent();
RadListView1.LayoutTemplate = Page.LoadTemplate("LayoutTemplate.ascx");
RadListView1.ItemTemplate = Page.LoadTemplate("ItemTemplate.ascx");
RadListView1.DataBind();
}
private List<
Student
> GetStudent()
{
List<
Student
> students = new List<
Student
>();
Student student = new Student();
student.Name = "Jim";
student.LastName = "McDonald";
students.Add(student);
Student student2 = new Student();
student2.Name = "Roza";
student2.LastName = "McDonald";
students.Add(student2);
return students;
}
}
public class Student
{
public string Name { get; set; }
public string LastName { get; set; }
}
ItemTemplate.ascx
Name : <%# Eval("Name") %><
br
/>
LastName : <%# Eval("LastName") %><
br
/>
LayoutTemplate.ascx
<
asp:PlaceHolder
ID
=
"itemPlaceholder"
runat
=
"server"
></
asp:PlaceHolder
>
Best Regards.
0
Accepted
Hello,
The error is cause because RadListView could not find the place holder control in the layout template.
This is due to the fact that the UserControl that is used as layout template is INamingContainer and FindControl does not resolve correctly.
However this is expected behavior you can even replicate it by using ListView instead of RadListView control.
To have this working you can inherit RadListView and override RetrivePlaceHolderControl method and provide custom implementation for finding control in container.
Greetings,
Nikolay
the Telerik team
The error is cause because RadListView could not find the place holder control in the layout template.
This is due to the fact that the UserControl that is used as layout template is INamingContainer and FindControl does not resolve correctly.
However this is expected behavior you can even replicate it by using ListView instead of RadListView control.
To have this working you can inherit RadListView and override RetrivePlaceHolderControl method and provide custom implementation for finding control in container.
Greetings,
Nikolay
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
temperory temperory
Top achievements
Rank 1
answered on 07 Jan 2011, 12:00 PM
Tanks.
[ToolboxData(
"<{0}:myRadListView runat=server></{0}:myRadListView>"
)]
public
class
myRadListView : Telerik.Web.UI.RadListView
{
protected
override
Control RetrivePlaceHolderControl(Control container,
string
placeholderId)
{
return
container.Controls[0].FindControl(placeholderId);
}
}