ITemplate.InstantiateIn Method
.NET Framework 2.0
When implemented by a class, defines the Control object that child controls and templates belong to. These child controls are in turn defined within an inline template.
Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)
Assembly: System.Web (in system.web.dll)
// Override the ITemplate.InstantiateIn method to ensure
// that the templates are created in a Literal control and
// that the Literal object's DataBinding event is associated
// with the BindData method.
public void InstantiateIn(Control container)
{
Literal l = new Literal();
l.add_DataBinding(new EventHandler(this.BindData));
container.get_Controls().Add(l);
} //InstantiateIn
// Create a public method that will handle the
// DataBinding event called in the InstantiateIn method.
public void BindData(Object sender, EventArgs e)
{
Literal l = (Literal)sender;
DataGridItem container = (DataGridItem)l.get_NamingContainer();
l.set_Text(((DataRowView)container.get_DataItem()).
get_Item(column).ToString());
} //BindData
Community Additions
ADD
Show: