We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Finding the row of the datatable bound to a given row in the grid

Thread ID:





11860 Mar 17,2004 10:34 AM UTC Mar 17,2004 11:16 AM UTC WinForms 2
Tags: GridControl
Raul Rosenthal
Asked On March 17, 2004 10:34 AM UTC

I have a bound grid and while iterating on the collection of selected rows I want to access the underlying datatable. Alas, if the user has altered the row order by sorting on a column, the index of a row in the grid is not the index of the same row in the datatable. How can I get a row in the bound datatable having the index of a row in the grid? Thank you.

Administrator [Syncfusion]
Replied On March 17, 2004 10:50 AM UTC

You can get the row object (either DataRowView or DataRow) through the currencymanager. This will allow you to access any fields (columns) in the datarow. //for a given rowIndex int position = this.Binder.RowIndexToPosition(rowIndex); CurrencyManager cm = (CurrencyManager) this.BindingContext[this.grid.DataSource, this.grid.DisplayMember]; DataView dv = (DataView) cm.List; DataRowView drv = dv[position]; //now you can access the fields with code like object colNameValue = drv["colName"];

Raul Rosenthal
Replied On March 17, 2004 11:16 AM UTC

I copied and pasted your sample, and it works as expected, though I don''t understand exactly why. Once more, thank you!


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon