Selecting Updated row in RadGrid

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

    Posted 22 Feb 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;
        GridPreOrder.DataBind();
     
    }

     

     

     

  2. Eyup
    Admin
    Eyup avatar
    3007 posts

    Posted 25 Feb 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 RadGridGetAllSelectedItemsImproved.zip sample provided in the following post and see the implementation demonstrated there:
    http://www.telerik.com/support/code-library/get-selected-items-through-all-pages#1eTU8nr-GUG8zfGgOGbIcA


    Regards,
    Eyup
    Telerik
    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top