Repopulating and Reselecting same Row in DevExpress Grid | Code2night.com
Code2night
  • Home
  • Blogs
  • Guest Posts
  • Tutorial
  • Post Blog
  • Register
  • Login
  1. Home
  2. Blogpost

Repopulating and Reselecting same Row in DevExpress Grid

Date- Jan 19,2024

1431

Devexpress Devexpress Grid

Repopulating and Reselecting Rows in DevExpress Grid

Repopulating and Reselecting Rows in DevExpress Grid

In a DevExpress Grid control, reselecting a row after repopulating the grid involves preserving the key value of the selected row and then reselecting it using the updated data. Below is a step-by-step guide to achieve this:

1. Save the Key Value of the Selected Row

When a user selects a row, save the key value of that row. The key value is usually obtained from the underlying data source. Replace "YourKeyFieldName" with the actual field name that represents the unique key for each row.

2. Repopulate the Grid

After repopulating the grid with updated data, update the grid's data source and refresh the view.

// Repopulate your grid here (e.g., fetching updated data from the database)
yourGridControl.DataSource = GetUpdatedData();
yourGridControl.RefreshDataSource();

3. Re-select the Row Using the Key Value

Find the new index of the row with the saved key value and select it.

int newIndex = gridView.LocateByValue("YourKeyFieldName", selectedRowKey);
gridView.FocusedRowHandle = newIndex;
gridView.SelectRow(newIndex);

Replace "YourKeyFieldName" with the actual field name used as the key.

Make sure to handle cases where the key value might not exist in the updated data (i.e., the row was deleted or the key value changed).

This approach assumes that your grid is bound to a data source where each row has a unique key. Adjust the field names and types according to your specific implementation.

So now you can select any row in devexpress gridview and after rebinding the grid the same row will be selected.

Comments

Tags

LinkedinLogin
LinkedinProfile
GetLinkedinProfile
C#
Aspnet
MVC
Linkedin
ITextSharp
Export to Pdf
AspNet Core
AspNet
View to Pdf in Aspnet
Model Validation In ASPNET Core MVC 60
Model Validation
Model Validation In ASPNET Core MVC
Model Validation In ASPNET
Image Compression in AspNet
Compress Image in c#
AspNet MVC
Free Download for Youtube Subscribers!

First click on Subscribe Now and then subscribe the channel and come back here.
Then Click on "Verify and Download" button for download link

Subscribe Now | 1190
Download
Support Us....!

Please Subscribe to support us

Thank you for Downloading....!

Please Subscribe to support us

Continue with Downloading
Be a Member
Join Us On Whatsapp Join Us On Facebook

Welcome To Code2night, A common place for sharing your programming knowledge,Blogs and Videos

  • Panipat
  • info@Code2night.com

Links

  • Home
  • Blogs
  • Tutorial
  • Post Blog

Popular Tags

Copyright © 2025 by Code2night. All Rights Reserved

  • Home
  • Blog
  • Login
  • SignUp
  • Contact
  • Terms & Conditions
  • Refund Policy
  • About Us
  • Privacy Policy
  • Json Beautifier
  • Guest Posts