Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
640
How to access DataItem object in Active Record for a grid event
posted

I bound my grid to a strongly typed collection and  I had trouble finding a way to extract and recast my  selected record into the corresponding data bound object.  So this is how you can do it. 

private void grdInboxItems_MouseDoubleClick(object sender, MouseButtonEventArgs e) {

// Check to make sure the selected Record is a DataRecord

if (grdInboxItems.ActiveRecord is DataRecord) {

// Cast the record passed in as a DataRecord

DataRecord myRecord = (DataRecord )grdInboxItems.ActiveRecord;

// Cast the DataRecord.DataItem into your CustomObject

CustomItem myItem = (CustomItem)myRecord.DataItem;}

  • 69686
    posted

    Hello,

    Basically this is the way you get the underlying object from the DataRecord. This code snipper should be working correctly (except if there is no ActiveRecord when you double-clicked). If you have a sample project that reproduces this issue, please attach it to your next post so that we can look into it and figure out the problem.

    Regards,

    Alex.