TemplateControl.LoadTemplate Method
.NET Framework 3.0
Obtains an instance of the ITemplate interface from an external file.
Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)
Assembly: System.Web (in system.web.dll)
The following code example demonstrates how to use the LoadTemplate method to add a user control as an alternating item to a DataList Web server control named DataList1. The user control implements the ITemplate interface and is contained in a file named Newtemplate.ascx.
void Page_Load(Object sender, System.EventArgs e)
{
if (!(get_IsPostBack())) {
DataList1.set_AlternatingItemTemplate(
LoadTemplate("newtemplate.ascx"));
DataList1.set_DataSource(CreateDataSource());
DataList1.DataBind();
}
}//Page_Load
Community Additions
ADD
Show: