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

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();
		}
}

Comments:

Add a Comment:

simple_captcha.jpg
(human authentication)


Ads

Categories

About

Random foliage

This website is meant to be a reference for ASP Dot Net developers. The entries are a compilation of things I've figured out how to do and that I deem useful to keep of track for future reference. Assumptions: web development with: C Sharp (vb sucks), visual studio 05/08, .net 3.5, meant for programmers. Written by: James Reategui.