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

how do I set the page focus to the insert button after clicking the add new record button to add a record

1 Answer 37 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 22 Jul 2010, 04:36 PM

I have a telerik radgrid that has an allows inserts.  After clicking the "Add New Record" button the textboxes appear with a couple of buttons.  One for Insert and one to cancel.  I would like the page focus to be on the insert button so when the user clicks the enter button, the insert button has the focus.

Does anyone know how to do this?

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 23 Jul 2010, 07:12 AM
Hello Richard,

Try the following code snippet in ItemDataBound event to put the focus on insert button.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted)
        {
            GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;
            LinkButton btnInsert = (LinkButton)insertItem.FindControl("PerformInsertButton");
            btnInsert.Focus();
        }
    }

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