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
How to get the DataRecord of all Record checked in the XamDataGrid


i have a Xamdatagrid with a field Checkbox on the Label  ,then i would like to enter in the values of all records that i checked (see photo below )   ....

with this is a code (i am using for  Button) i can get the 3 Records but from the First Row,Second Row and Third Row  instead i would like to get the records checked..

     for (int i = 0; i < xamDataGrid1.SelectedItems.Records.Count; i++)
                 string first = (xamDataGrid1.Records[i] as DataRecord).Cells[0].Value.ToString();
                 string second = (xamDataGrid1.Records[i] as DataRecord).Cells[1].Value.ToString();

  • 28190
    Offline posted

    Hello An,

    From the screenshot that you have provided, I cannot quite tell exactly how you are placing the Checkbox in your XamDataGrid Field, but I imagine you are likely using a TemplateField or a CellValuePresenter style modification or something of the like.

    Either way, I would expect that the Checkbox that you are placing in your Field is tied back to a property on your underlying data item using a binding, likely to the IsChecked property of those Checkboxes. As such, in order to get the checked rows, I would recommend first querying your data to get the underlying data items that have a value of "true" for this bound property. In doing so, you can then use the XamDataGrid.GetRecordsFromDataItems method to get the actual record objects. You can read further about this method here.

    Please let me know if you have any other questions or concerns on this matter.

Reply Children