This is a migrated thread and some comments may be shown as answers.

Bound Data Not Showing up on refresh or export

4 Answers 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dustin Dodson
Top achievements
Rank 1
Dustin Dodson asked on 18 May 2012, 06:29 PM
I have a unique situation. I am trying to get a field to subtract from a total based on a column in the grid and an overall total.

I am able to get this to work when the grid is first created...

here is my code:

The grid is created from a child class that is a property of the parent class using the OnNeedDataSource method. The Total amount is in the parent class.

public
 void grdSiteFunding_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    SiteFundingCalculation sfc = new SiteFundingCalculation(2010);
    if (TotAmnt <= 0)
    {
        TotAmnt = sfc.CalculateNetFunds();
        TotLeft = TotAmnt;
    }
    if (TotLeft <= 0)
    {
        TotLeft = TotAmnt;
    }
     
    //Bind the grid to the child class.
    grdSiteFunding.DataSource = sfc.FundingDetails.ToList();           
}


So after getting the total I am doing my calculation after the grid is bound using data in a column of the child class.
protected decimal TotAmnt = 0;
protected decimal TotLeft = 0;

public
void grdSiteFunding_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem dItem = (GridDataItem)e.Item;
            decimal oFunds = 0;
            decimal cFunds = 0;
            oFunds = decimal.Parse(dItem["OverriddenFunding"].Text.Replace("$", "").Trim());
            cFunds = decimal.Parse(dItem["CalculatedFunding"].Text.Replace("$", "").Trim());
            decimal retVal = 0;
            if (oFunds > 0)
            {
                if (oFunds <= TotLeft)
                {
                    retVal = TotLeft - oFunds;
                    TotLeft -= oFunds;
                }                       
                else
                {
                   retVal = TotLeft;
                    if (TotLeft != 0)                       
                        TotLeft -= TotLeft;
                }
            }
            else if (TotLeft >= cFunds)
            {
                if (cFunds <= TotLeft)
                {
                    retVal = TotLeft - cFunds;
                    TotLeft -= cFunds;
                }                       
                else
                {
                    retVal = TotLeft;
                    if (TotLeft != 0)
                        TotLeft -= TotLeft;
                }
            }               
            else
            {
                retVal = TotLeft;
                if (TotLeft != 0)
                    TotLeft -= TotLeft;
            }
 
            dItem["RemainingFunds"].Text = retVal.ToString("C");             
        }
    }

So basically it shows the funding being deducted from the total amount for every row in the grid until the total amount left is 0.
This works great when the grid first loads, but if I hit the refresh button on the grid or try to export this to pdf, the calculation disappears.

Of course I have Ajax in the page for updating the grid etc. So I turn it off when I export to pdf like I'm supposed to, but the data still doesn't show.

The rest of the bound data does show up on refresh and on export, just this column doesn't get updated. I have stepped through the code and it the data gets created on refresh or export, but still doesn't show up when the page is rendered or exported.

Any ideas or help would be appreciated. Let me know if you need any more info.

Thanks,

Dustin

4 Answers, 1 is accepted

Sort by
0
Dustin Dodson
Top achievements
Rank 1
answered on 18 May 2012, 07:45 PM
UPDATE:
I have figured out that sorting, rearranging and grouping the columns also makes the total not show up.

Re-sizing the columns however does not cause this. Hope that helps narrow it down...
 

UPDATE 2:
I fix the rearranging issue by setting EnableViewState="True". Still does not work on refresh and export however.

UPDATE 3:
I have also figured out that putting it in edit mode shows the calculations... still will not show the calculations on refresh or export.

Thanks,

Dustin
0
Dustin Dodson
Top achievements
Rank 1
answered on 22 May 2012, 05:08 PM
Can no one help me with this issue?

I would hate to open a support ticket for something small I might be overlooking.

I also figured out that if you put the grid in Edit mode it also does the calculation. I'm really stuck on this one. Any help would be appreciated.

Thanks,

Dustin
0
Daniel
Telerik team
answered on 23 May 2012, 03:33 PM
Hi Dustin,

I tired to reproduce the problem on my end but unfortunately to no avail. Download the attached demo and let me know how to modify the website in order to recreate your scenario.

Thanks,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Dustin Dodson
Top achievements
Rank 1
answered on 23 May 2012, 03:35 PM
Hey Daniel I just submitted a support ticket with more information. Like how I have my grid set up etc.

It's ticket number: 547208 thanks for the reply though
Tags
Grid
Asked by
Dustin Dodson
Top achievements
Rank 1
Answers by
Dustin Dodson
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or