Link to home
Start Free TrialLog in
Avatar of Whing Dela Cruz
Whing Dela CruzFlag for Anguilla

asked on

DataGrid LoadingRow with DataGridRowEventArgs

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?
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

can u post the whole code?
Avatar of Whing Dela Cruz

ASKER

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...
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>?
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...
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;
        }
Is the setter on prod.Balance throwing an exception?
ASKER CERTIFIED SOLUTION
Avatar of Whing Dela Cruz
Whing Dela Cruz
Flag of Anguilla image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks