New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial
Accessing Controls
Accessing controls in the LayoutTemplate
To get reference to a control in RadListView LayoutTemplate you can use its FindControl(controlId) method.
C#
protected void RadListView1_PreRender(object sender, EventArgs e)
{
Label lbl = RadListView1.FindControl("Label1") as Label;
}
Accessing controls in the ItemTemplate
To access a control in RadListView item you can handle the ItemCreated event as shown below:
C#
protected void RadListView1_ItemCreated(object sender, RadListViewItemEventArgs e)
{
if (e.Item is RadListViewDataItem)
{
Label label = e.Item.FindControl("Label1") as Label;
}
}
Accessing controls in the EditItemTemplate/InsertItemTemplate
If the RadListView item is in edit mode you can get reference to the respective RadListViewEditableItem instance and call the FindControl(controlId) method for it.
C#
protected void RadListView1_ItemCreated(object sender, RadListViewItemEventArgs e)
{
if (e.Item is RadListViewEditableItem && e.Item.IsInEditMode)
{
TextBox myControl = e.Item.FindControl("TextBox1") as TextBox;
}
}
If the RadListView item is in insert mode you can reference the control the same way as in edit mode.
C#
protected void RadListView1_ItemCreated(object sender, RadListViewItemEventArgs e)
{
if (e.Item is RadListViewInsertItem && e.Item.IsInEditMode)
{
TextBox myControl = e.Item.FindControl("TextBox1") as TextBox;
}
}