Wednesday, May 23, 2012

Find Label Control from Item Temple of RadGrid

Problem:

I am using GridTemplateColumn in RadGrid and I want find the label control which is in grid's ItemTemplate to update record.

I am using this code in grid's updatecommand,

VB CODE:
Dim Label1 As Label = CType(e.Item.FindControl("Label1"), Label)

but control is not found thus there is (nothing) in Label1.

Solution:

Try this,

VB CODE:
Dim Label1 As Label = DirectCast(CType(e.Item, GridEditFormItem).OwnerTableView.Items(e.Item.ItemIndex).FindControl("Label1"), Label)