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
120
How to convert a selected record to a class
posted

Hi,

I Have xamdatagrid it contains the collection of Customer records.

it is bind with customerList

Ex: List<Customer>CustomerList = new List<Customer>();

i have binded the "CustomerList" to xamdatagrid.

 my problem is: i have selected 3 records and  click on one button i need to get the record type as Customer.

 i am  unable to type cast the selected records to customer.

 Thanks in advance,

 

 

  • 69686
    Verified Answer
    posted

     Hello,

    You can get the item in the cell as its type when getting the DataRecord ( the 3 you have selected ) and casting its DataItem property to the desired type.

    DemoCustomer demoCustomer = dataRecord.DataItem as DemoCustomer; 

    Hope this helps.