Focus Grid Edit Item on Insert or Edit
Posted on: Wed Jan 20 13:02:41 -0800 2010. Updated on: Wed Jan 20 13:04:22 -0800 2010.
Category: Telerik Controls and Sitefinity
Category: Telerik Controls and Sitefinity
With Telerik RadGrid, when you hit the Add New Record and the editable form comes up, the first textbox or dropdown is not selected focused by default. This code will do this. Attaches to Behavior: ItemDataBound
protected void RadGridServiceTypes_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if (e.Item is Telerik.Web.UI.GridEditableItem && e.Item.IsInEditMode)
{
Telerik.Web.UI.GridEditableItem form = (Telerik.Web.UI.GridEditableItem)e.Item;
TextBox comboBox = (TextBox)form["ServiceName"].Controls[1];
comboBox.Focus();
}
}