Selecting Updated row in RadGrid

2 posts, 0 answers
  1. Salman
    Salman avatar
    6 posts
    Member since:
    Feb 2016

    Posted 22 Feb 2016 Link to this post

    In a from with RadGrid, data of selected row is read and assigned to related textboxes, RadComboBox, RadDatePicker above Grid. There is an update button as well to make change to the fields. I want to refresh RadGrid or updated row after making change. everything works but after making changes, I want the last row that I was working on it to be selected. with below code, first row is selected:

    protected void BtnUpdate_Click(object sender, EventArgs e)
        Update(); // function for updating fields
        //Below are codes to updating grid after making changes but it
        //selects the first row
        DataTable dp = Dbo.PreOrder.Grid();
        GridPreOrder.DataSource = dp;




  2. Eyup
    Eyup avatar
    3296 posts

    Posted 25 Feb 2016 Link to this post

    Hello Salman,

    Please make sure that you are not using DataBind() to bind the grid. Performing complex grid operations such as Inserting, Deleting, Updating, Hierarchy relations, Grouping, Exporting, Paging, Sorting, Filtering, etc. require accommodating appropriate database operations.  Therefore, we suggest you to avoid Simple Databinding and strongly recommend the use of more advanced databinding methods, which automatically handle the aforementioned functions:
    Declarative DataSource
    Programmatic Data Binding

    You can use Rebind() to refresh the grid content.

    Basically, when you rebind the grid, the selection is cleared. You can preserve the index of the Selected index before the updating in a HiddenField control. You can also examine the sample provided in the following post and see the implementation demonstrated there:

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top