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

Selecting Updated row in RadGrid

1 Answer 352 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Salman
Top achievements
Rank 1
Salman asked on 22 Feb 2016, 08:19 AM

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();
 
}

 

 

 

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 25 Feb 2016, 09:51 AM
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
Tags
Grid
Asked by
Salman
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or