Solved

DataGrid LoadingRow  with DataGridRowEventArgs

Posted on 2012-04-01
10
2,045 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
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…

856 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