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

Focus TextBox on RadGrid when edit.

3 Answers 78 Views
Window
This is a migrated thread and some comments may be shown as answers.
Ivan Ruiz
Top achievements
Rank 1
Ivan Ruiz asked on 11 Jul 2009, 07:49 PM
Hi,

How can I focus a control when you edit a RadGrid?

I need to focus a TextBox, located on the EditItemTemplate when the user click an edit action on the RadGrid

Ivan Ruiz

3 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 14 Jul 2009, 03:13 PM
Hi Ivan,

Try getting your text box when your edit item is created:

void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    if (e.Item is GridEditFormItem && e.Item.IsInEditMode) 
    { 
        (e.Item.FindControl("TextBox"as TextBox).Focus(); 
    } 


Best wishes,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Emily Fong
Top achievements
Rank 1
answered on 23 Aug 2012, 05:57 AM
Hi,

I have a problem on setting focus on the textbox in RadGrid.  I did as you said in ItemCreated.  However, the textbox is focus random.  Sometime, it can focus on the textbox but sometime not.
Any idea?
Thanks!

Best Regards,
Emily
0
Eyup
Telerik team
answered on 27 Aug 2012, 11:56 AM
Hello Emily,

I have created a sample RadGrid web site with Edit Form Template. On my side everything works as expected and the defined TextBox gets focused as expected. Please check out the attached application and try to distinguish the crucial differences between our projects.

Greetings,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Window
Asked by
Ivan Ruiz
Top achievements
Rank 1
Answers by
Veli
Telerik team
Emily Fong
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or