Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Im using following code to add loding row event to datagrid in wpf


XML
grdpurchase.LoadingRow += new EventHandler<DataGridRowEventArgs>(grdpurchase_LoadingRow);
            grdpurchase.ItemsSource = arr;//ArrayList
            grdpurchase.LoadingRow -= new EventHandler<DataGridRowEventArgs>(grdpurchase_LoadingRow);


but This is not working after add the item source please help me to solve tis issue
Im using C#
Posted

1 solution

I think your Ordering of Attaching and Detaching Might become Problamatic Here. In Ideal Situation It should be Detaching First and then attaching the event.Where as You had done it Totally Reverse. Please Check it by Considering this facts by Changing code as below.


XML
 grdpurchase.LoadingRow -= new EventHandler<DataGridRowEventArgs>(grdpurchase_LoadingRow);
grdpurchase.LoadingRow += new EventHandler<DataGridRowEventArgs>(grdpurchase_LoadingRow);
 grdpurchase.ItemsSource = arr;//ArrayList
 
Share this answer
 
Comments
Member 10296413 20-Aug-14 8:12am    
I'm written code to find the sum of Amount column in the grid In loading row event its working fine
but when i Click on header it calculating the sum again to solve this i'm keeping that event Active only binding time
but that code not removing the event after bind
ashok rathod 21-Aug-14 2:07am    
Please check that order of Loading Row and your Click on Header. I think it will first call your Loading Row. What you can do is create one page level variable and assigned it with first time true and then once loadingrow is completed make it false after that when your header gets clicked at that time this variable value will be false and in your loading row mechanism you can check this global variable value. This might be dirty trick. but i think will work for you,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900