Code2night
  • Home
  • Guest Posts
  • Tutorial
  • Languages
    • Angular
    • C
    • C#
    • HTML/CSS
    • Java
    • JavaScript
    • Node.js
    • Python
    • React
    • SQL Server
    • TypeScript
  • Post Blog
  • Tools
    • JSON Beautifier
    • HTML Beautifier
    • XML Beautifier
    • CSS Beautifier
    • JS Beautifier
    • PDF Editor
    • Word Counter
    • Base64 Encode/Decode
    • Diff Checker
    • JSON to CSV
    • Password Generator
  • Register
  • Login
  1. Home
  2. Blogpost

Repopulating and Reselecting same Row in DevExpress Grid

Date- Jan 19,2024

3170

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.

S
Shubham Batra
Programming author at Code2Night โ€” sharing tutorials on ASP.NET, C#, and more.
View all posts โ†’

Related Articles

DevExpress Dropdown Items Overlapped by Popup
Sep 10, 2022

Comments

Tags

AspNet
C#
programming
AspNet MVC
c programming
AspNet Core
C
software development
tutorial
MVC
memory management
Paypal
coding
coding best practices
data structures
programming tutorial
tutorials
object oriented programming
Slick Slider
StripeNet
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 | 1760
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
Code2Night

A community platform for sharing programming knowledge, tutorials, and blogs. Learn, write, and grow with developers worldwide.

Panipat, Haryana, India
info@code2night.com
Quick Links
  • Home
  • Blogs
  • Tutorials
  • About Us
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Guest Posts
Free Dev Tools
  • JSON Beautifier
  • HTML Beautifier
  • CSS Beautifier
  • JS Beautifier
  • Password Generator
  • QR Code Generator
  • Hash Generator
  • Diff Checker
  • Base64 Encode/Decode
  • Word Counter
By Language
  • Angular
  • C
  • C#
  • HTML/CSS
  • Java
  • JavaScript
  • Node.js
  • Python
  • React
  • SQL Server
  • TypeScript
© 2026 Code2Night. All Rights Reserved.
Made with for developers  |  Privacy  ยท  Terms
Translate Page