Solved

DataGrid LoadingRow  with DataGridRowEventArgs

Posted on 2012-04-01
10
2,010 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
Comment Utility
can u post the whole code?
0
 

Author Comment

by:Whing Dela Cruz
Comment Utility
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
Comment Utility
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
 

Author Comment

by:Whing Dela Cruz
Comment Utility
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 4

Expert Comment

by:Sathish DV
Comment Utility
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
Comment Utility
Is the setter on prod.Balance throwing an exception?
0
 

Accepted Solution

by:
Whing Dela Cruz earned 0 total points
Comment Utility
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
Comment Utility
Thanks
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now