Weird C# ASP.NET Casting/Truncation issue

Bohica69

Gawd
Joined
Jul 12, 2005
Messages
676
I've got a WEIRD issue going on that's driving me NUTS. I've got an ascx that calls some code in the DataGrid ItemDataBound event handler and for some reason one value, for lack of a better word is getting munged.
Here's the pertentant code - I've removed things that shouldn't matter for brevity.
RateDetail is a class I wrote that has several properties one of which is called APRFees - it (the APRFees) is a double.

Code:
private void dgRate_ItemDataBound(object sender, DataGridItemEventArgs e)
{......RateDetail view = (RateDetail)e.Item.DataItem;
..... Bunch of code here - setting other items in the datagrid
// Here's where I get the value of the APRFees. 
double tempAPRFees = view.APRFees; 
lblAPR.Text = tempAPRFees.ToString("F3") + "%";

Ok, so as you can see I'm setting a label in one grid row to the value of the current item it's bound to. The problem is that the view.APRFees value is getting CHANGED somehow.
Here's part of the decleration of the APRFees property
Code:
 public double APRFees
        {
            get
            {.... Bunch of code to figure out the right value 

                tempAPRCalc.Calculate();
                return tempAPRCalc.value;
            }

Ok, here's the part that's causing me problems - tempAPRCalc.value is a double. When I step thru the code and watch the value of tempAPRCalc.value inside the get code of the APRFees property the value at the point I'm having problems is 5.416. When I step OUT of that function and go the the line at

double tempAPRFees = view.APRFees;

The value is 5.424? WTF? That makes NO sense to me - I'm walking thru the code, I see it hitting the getter for the property, I see it's going to return the right value and then blammo, it's changed? Any ideas?

Thanks
 
I don't think you're giving us enough information to diagnose your problem for you. You'll have to debug through it and see what's going on yourself. If you want someone to debug it for you, you'll have to provide all of your code and instructions to set it up, as well as reproduce the problem.
 
Back
Top