views:

135

answers:

1

Hello,

I am having some trouble with CheckBoxes in a DataGrid. The CheckBoxes are not bound to the entities that are populating the datagrid because there isn't a property on the entities for it. Basically what I am trying to do is when I check a CheckBox I add the ID of the item in that row to a list to be returned. The problem I am having is when I check some CheckBoxes and the page with the DataPager it uncheckes the CheckBoxes on the first page and tries to remove them but the DataGrid has already gone to the second page so it throws a null reference exception because it can't find those items anymore. How can I fix this? If you need me to post my code just let me know.

A: 

One approach to this is to customise the partial class that Entity Framework has created for you. Add your boolean property to the entity class. Now you can bind the checkbox column as any other column ant the data will be maintianed between paging.

You can then just enumerate through the items currently in the context select those have been checked.

AnthonyWJones
Can you think of any other way to accomplish what I am trying to do besides that? I have thought about doing it that way but I didn't really want to add another property to the entity. Unless that would make what I'm trying to do a lot easier then I might just have to go with that solution.
Brett
Yes it will make it a lot easier, I didn't really put the stress in the right place. This is correct way to handle this sort of problem. You need only fiddle with the partial entity class in the silverlight project, the web project doesn't need to know about it.
AnthonyWJones
Where should I put this partial entity class? Oh btw I'm using .Net Ria servies will that change anything?
Brett