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

After I click the "Add New Record" button, how do I set focus to the first column Insert textbox

1 Answer 139 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 26 Jul 2010, 04:12 PM
I have a radgrid that is tied to an objectdatasource that allows inserts.  When I click the "Add New Record" button at the top of the grid, I want to set focus to the first columns textbox for input. 

How do I do this?

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 27 Jul 2010, 05:43 AM
Hello Richard,

Try the following code snippet to set focus on a TextBox in insert form.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
   {
      if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted)
       {
           GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;
           TextBox txt = (TextBox)insertItem["ColumnUniqueName"].Controls[0];
           txt.Focus();
       }
   }

Also please take a look at the following documentation.
Focus the text boxes in the edit control

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