0

我有 Gridview 我想在其中隐藏两列但需要访问它们的值,所以我将它们保存在 dataKey

在这两个数据键字段中,一个是申请费..它包含双格式的值,现在我想要这些值进行计算...所以我使用以下方法从数据键申请费中获取值

   double ApplicationFees =  double.Parse(GridApplicationsList.DataKeys[row.RowIndex].Values[1].ToString());

现在例如,如果我在 gridview 中的申请费值为 220.75,但上面的代码给了我 220.0,我如何从 datakey 获得完整的双倍值

4

1 回答 1

0

It might be possible that you are referencing a wrong field from the DataKeyNames collection by saying Values[1].

Since you're storing two columns in the DataKeyNames property, always try referencing them using by it's name rather than by it's index like below. In case if you are adding one more field to the DataKeyNames property in future then you don't have to change the code to update the index position for the keys.

double ApplicationFees =  double.Parse(GridApplicationsList.DataKeys[row.RowIndex].Values["APP_FEES"].ToString());
于 2014-10-24T17:29:13.593 回答