3

I try to pass the value to DataRow type variable from custom collection like the codes bellow:

GridHitInfo downHitInfo = null;
DataRow row = gridView3.GetDataRow(downHitInfo.RowHandle);

But as I know that if the view's data source is a custom collection of objects, the GetDataRow method returns null (Nothing in Visual Basic). If the view's data is supplied by the System.Data.DataTable or System.Data.DataView object, the System.Data.DataRow object representing a specific row is returned."

And the XPCollection is "a custom collection of objects".

Is there any way that I could do to get the value from

gridView3.GetDataRow(downHitInfo.RowHandle)?

Is there any converter or something needed?

Toon Krijthe
  • 52,876
  • 38
  • 145
  • 202
  • See my answer to this post http://stackoverflow.com/questions/12762617/how-to-get-the-selected-row-values-of-devexpress-xtragrid – Saif Khan Oct 09 '12 at 13:43

1 Answers1

1

You can't get the DataRow object when the underlying Grid's data source not is DataTable or DataView. When the data source's type is XPCollection you should use the GetRow() method instead of the GetDataRow() method to get objects which correspond to grid rows:

var xpCollection = new XPCollection<Person>();
gridControl1.DataSource = xpCollection;
//...
Person person = (Person)gridView1.GetRow(rowHandle);
DmitryG
  • 17,677
  • 1
  • 30
  • 53
  • "You can't get the DataRow object when the underlying Grid's data source not is DataTable or DataView."...I don't believe that is correct. – Saif Khan Oct 09 '12 at 13:42