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

Binding Data Index to Row Index

2 Answers 601 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kim
Top achievements
Rank 1
Kim asked on 28 Dec 2015, 02:04 AM

 

hello.

Please teach me the way.

 

GridView SourceData : Binding : List, DataTable...

 1. Binding Data  Index => GridView Row Index

2. GridView Row Index => Binding Data Index

 

 

2 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 28 Dec 2015, 11:51 AM
Hello Kim,

Thank you for writing.

RadGridView maps its rows to the data source object. At any time you can get a reference for the data bound object  of a row by accessing its DataBoundItem property: 
object data = this.radGridView1.CurrentRow.DataBoundItem;
The indices of the rows in the grid correspond to the indices of the data bound objects.

If you will be working with a DataTable the data bound item would be a DataRowView and if you have a collection of a custom object its type would be the type of your object. Detailed information about the different options to bind RadGridView are discussed in the following section of our documentation: Populating with Data.  Please note that in order to reflect custom changes in your model object class it would need to implement the INotifyPropertyChanged interface. An example is available here: Reflecting Custom Object Changes in RGV.

I am sending you attached a project containing examples for binding to a DataTable and a collection of data objects. Besides the project, I am also sending you a short animation showing the result on my end.

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
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
0
Kim
Top achievements
Rank 1
answered on 29 Dec 2015, 03:42 AM

Thank you for your prompt reply. Express deep gratitude.

 

Tags
GridView
Asked by
Kim
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Kim
Top achievements
Rank 1
Share this question
or