This is a migrated thread and some comments may be shown as answers.

Could not find control in OnItemCommand event

1 Answer 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Amit
Top achievements
Rank 1
Amit asked on 09 Aug 2011, 10:56 AM
Hi,

How should i find controls inside RadGrid OnItemCommand event??

protected void grdMessageState_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
           if (e.CommandName == RadGrid.InitInsertCommandName)
                {
                    SysXTextBox testName = e.Item.FindControl("txtStateName") as SysXTextBox;
                    testName.Focus();
                }
            }
        }

Thanks
Amit Choudhary

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 09 Aug 2011, 12:25 PM
Hello Amit,

I am not quite sure about your requirement. Here is the sample code that I tried to access TextBox in ItemCommand event.
C#:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.PerformInsertCommandName)
    {
     GridEditFormInsertItem insertedItem = (GridEditFormInsertItem)e.Item.OwnerTableView.GetInsertItem();
     TextBox txtbx = (TextBox)insertedItem.FindControl("txtStateName");
     txtbx.Focus();
    }
}

Thanks,
Princy.
Tags
Grid
Asked by
Amit
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or