简体   繁体   中英

In gridview Datakey field contains double value but retutns only integer part,how to get complete double value

I'm having Gridview in which two columns I want to hide but need to acces their value so I keep them in dataKey

out of these two datakey field one is application fees..which contains values in double format, now I want these values for calculation...so I used following method to get the values from datakey application fee

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

now for eg if my application fees value is 220.75 in gridview but it gives me 220.0 with above code, how do I achive complete double value from datakey

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());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM