I have a DataGrid bound to a LinqDataSource and on my master table I have 3 DataKeys. One of these DataKeys is NULL for some of the rows in the grid. When I go to update a row in a popup form and submit the changes I get the dreaded "Object reference not set to an instance of an object" error (OriginalValueMatches is the last method in the stack trace).
Now if the grid doesn't contain any rows where that datakey is NULL, it works fine, alternatively if I remove that datakey it will also work fine. However it doesn't seem to matter if I'm updating a record where that field is NULL or not, it will still error should at least one row in the grid have a NULL datakey. The datakey corresponds with a GridDropDownColumn in the Grid (although it doesn't seem to matter if I have the Empty... attributes set or not or even if I remove this column totally from the grid)
For the moment I've got around this problem with another database query to get the value when I need it, but would prefer to use DataKeys and would like to get to the bottom of this so I don't get stuck in the future. Is this a bug? Is there a workaround? Am I allowed to have a DataKey that is sometimes NULL?
Now if the grid doesn't contain any rows where that datakey is NULL, it works fine, alternatively if I remove that datakey it will also work fine. However it doesn't seem to matter if I'm updating a record where that field is NULL or not, it will still error should at least one row in the grid have a NULL datakey. The datakey corresponds with a GridDropDownColumn in the Grid (although it doesn't seem to matter if I have the Empty... attributes set or not or even if I remove this column totally from the grid)
<telerik:GridDropDownColumn DataSourceID="ldsBrand" DataField="BrandID" HeaderText="Brand Name" ListTextField="BrandName" ListValueField="BrandID" AllowFiltering="false" EnableEmptyListItem="true" EmptyListItemText="-- No Brand --" EmptyListItemValue="" ConvertEmptyStringToNull="true" EditFormColumnIndex="0" UniqueName="Brand" />
For the moment I've got around this problem with another database query to get the value when I need it, but would prefer to use DataKeys and would like to get to the bottom of this so I don't get stuck in the future. Is this a bug? Is there a workaround? Am I allowed to have a DataKey that is sometimes NULL?