Solved

DataGrid LoadingRow  with DataGridRowEventArgs

Posted on 2012-04-01
10
2,050 Views
Last Modified: 2013-11-12
I've got a problem with the DataPager when I used LoadingRow.

        public void LoadFund(Object sender, DataGridRowEventArgs e)
        {
            MyBalance prod = e.Row.DataContext as MyBalance;
            prod.Balance = 90;
        }

If I use this DataGridRowEventArgs my DataPager won't work anymore. Why Please?
0
Comment
Question by:Whing Dela Cruz
10 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 37794848
can u post the whole code?
0
 

Author Comment

by:Whing Dela Cruz
ID: 37794929
Hi! In xaml odes are follows;

<Grid x:Name="LayoutRoot" Background="White">
        <ScrollViewer BorderThickness="0"  VerticalScrollBarVisibility="Auto" Padding="12,0,12,0" Margin="-12">  
            <StackPanel Margin="0,12,0,12" Orientation="Vertical" >
                <StackPanel Margin="0,12,0,12" Orientation="Vertical" >
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="4,4,4,0" Height="32" Background="{StaticResource HoverHyperlinkForegroundColorBrush}">
                        <sdk:Label Height="22" x:Name="lblStart" Width="33" Content="Start" Foreground="Tomato" FontWeight="Bold"/>
                        <sdk:DatePicker Height="22" x:Name="datePicker1" Width="100" Background="WhiteSmoke" Foreground="Black"/>
                        <sdk:Label Height="22" x:Name="lblEnd" Width="33" Content="End" Foreground="Tomato" FontWeight="Bold"/>
                        <sdk:DatePicker Height="22" x:Name="datePicker2" Width="100" Background="WhiteSmoke" Foreground="Black"/>
                       
                        <data:DataPager Height="26" Name="dataPager1" PageSize="12" Source="{Binding Data, ElementName=employeeDataSource}"
                                        Width="200" AutoEllipsis="True" NumericButtonCount="3"/>
                        <Button x:Name="Add" Content="Add new" Click="Add_Click"></Button>
                        <Button x:Name="Edit" Content="Edit" Click="Edit_Click"></Button>
                        <Button x:Name="Ac" Content="ac" Click="Activate_Click"></Button>
                    </StackPanel>
                </StackPanel>
                <riaControls:DomainDataSource Name="employeeDataSource" LoadSize="100" QueryName="GetMyBalancesQuery"
                                AutoLoad="True">
                    <riaControls:DomainDataSource.DomainContext>
                        <ds:InOutOrganizationContext/>
                    </riaControls:DomainDataSource.DomainContext>

                </riaControls:DomainDataSource>

                <sdk:DataGrid MinHeight="100" IsReadOnly="True" AutoGenerateColumns="False" Margin="4,4,4,0" RowBackground="Cornsilk"              
                               AlternatingRowBackground="BlanchedAlmond" ItemsSource="{Binding Data, ElementName=employeeDataSource}"              
                               x:Name="BalanceGrid"  Background="White" Foreground="Black" LoadingRow="LoadFund">
                    <sdk:DataGrid.Columns>
                        <sdk:DataGridTextColumn Binding="{Binding TrxCode}" Header="Code" Width="80" />
                        <sdk:DataGridTextColumn Binding="{Binding TheDate, Mode=TwoWay, StringFormat=MMMM dd\, yyyy}" Header="Date" Foreground="Black"  Width="120" />
                        <sdk:DataGridTextColumn Binding="{Binding EncodersName}" Header="Encoded By:" Width="110" />
                        <sdk:DataGridTextColumn Binding="{Binding A_In, StringFormat=#\,##0.00}" Header="(+) In" Foreground="Blue" Width="75" />
                        <sdk:DataGridTextColumn Binding="{Binding A_Out}" Header="(-) Out" Foreground="Black"  Width="68" />
                        <sdk:DataGridTextColumn Binding="{Binding Balance, StringFormat=#\,##0.00}" Header="Balance" Foreground="Blue" Width="75"/>
                        <sdk:DataGridTextColumn Binding="{Binding ReceiptNo}" Header="Receipt no" Width="110" />
                        <sdk:DataGridTextColumn Binding="{Binding Purpose}" Header="Purpose:" Width="110" />
                       
                    </sdk:DataGrid.Columns>
                </sdk:DataGrid>
                <TextBox Text="{Binding Path=SelectedRecord.Purpose, Mode=TwoWay}"></TextBox>
                <TextBox x:Name="MyText"></TextBox>
            </StackPanel>
        </ScrollViewer>

    </Grid>

while on xaml.cs codes are as follows;
        public void LoadFund(Object sender, DataGridRowEventArgs e)
        {
            MyBalance prod = e.Row.DataContext as MyBalance;
            if (prod.A_In > 0)
            {
                e.Row.Background = new SolidColorBrush(Color.FromArgb(255, 100, 100, 100));
                prod.Balance = 90;
            }
            else
            {
                e.Row.Background = new SolidColorBrush(Color.FromArgb(255, 200, 200, 200));
            }
        }

at the time that i use "prod.Balance = 90;" the pager will not work, but if I will not use that everything is working...
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 37795022
so the only problem is with this line:   prod.Balance = 90; ???
try this:
comment the following line in your xaml:
    <sdk:DataGridTextColumn Binding="{Binding Balance, StringFormat=#\,##0.00}" Header="Balance" Foreground="Blue" Width="75"/>

now run your app with prod.Balance = 90;
does the pager works now>?
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

Author Comment

by:Whing Dela Cruz
ID: 37795281
Hi! sedgwick, It doesn't work. I tried it but got the same result. The DataPager is not working so I could not move to another page...
0
 
LVL 4

Expert Comment

by:Sathish DV
ID: 37826933
Hi ERWIIN,

try the below code..

public void LoadFund(Object sender, DataGridRowEventArgs e)
        {
            MyBalance prod = e.Row.DataContext as MyBalance;
            prod.Balance = 90;
            BalanceGrid.DataContext = prod;
        }
0
 
LVL 7

Expert Comment

by:vbigham
ID: 37834051
Is the setter on prod.Balance throwing an exception?
0
 

Accepted Solution

by:
Whing Dela Cruz earned 0 total points
ID: 37905201
Hi all! Sorry for the late response. I've been in a long vacation. I may now trying all suggested answer given above. Thanks!
0
 

Author Closing Comment

by:Whing Dela Cruz
ID: 37940804
Thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Testing of the web services 1 47
How to filter by key press ? 6 54
why JSON Array data not binding on Model ASP.NET ? 1 28
Json and ajax 1 19
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question