onsdag 16 januari 2013

asp.net datakey does not work sometimes

Had problems reading data from DataKeys in my GridView, for example:

GridViewDistributionHoldRVI.DataKeys[GridViewDistributionHoldRVI.EditIndex][
"DistributionOrderId"].ToString();Returned null.


The problem araised after a time, when developing this function.
The problem was cauesed by that somtimes the value for a Key before the one I tried to read had a value of null, the the values after this could also not be read.

In my example DORInstanceId was null:

DataKeyNames
="DORInstanceId,DistributionOrderId,MainType,ChassisNo,BusinessAreaCode,DistributionPriority,VehicleIdNo,StockCode,BlockCode,HoldDate"

Initiating this value to blank solved this problem.

Inga kommentarer:

Skicka en kommentar