This is a migrated thread and some comments may be shown as answers.

Selection of items is null, SelectionEventArgs says item is "removed"

2 Answers 26 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Johannes
Top achievements
Rank 1
Johannes asked on 17 Apr 2013, 08:03 AM
Hi everyone,

I have an issue with selection of data from the RadGridView. The issue is that suddenly, after updating my Telerik Controls for WPF to 2013.1.220.40 it started hating my selection code.

I have the following XAML:
<telerik:RadGridView
    Name="dgOrderOverview"
    AutoGenerateColumns="False"
    SelectionChanged="dgOrderOverview_SelectionChanged"
    SelectionMode="Single"
    SelectionUnit="FullRow"
    IsReadOnly="True"
    CanUserDeleteRows="False"
    CanUserInsertRows="False"
    IsBusy="False"
    telerik:StyleManager.Theme="Windows8"
    >
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=ShipmentID}" Header="ShipmentID" UniqueName="ShipmentID" IsReadOnly="True" IsVisible="False" />
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=OrderNo}" Header="Order no" UniqueName="OrderNo" IsReadOnly="True" />
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=Pieces}" Header="Pieces" UniqueName="Pieces" IsReadOnly="True" />
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=ReceiverName}" Header="Receiver" UniqueName="ReceiverName" IsReadOnly="True" />
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

Which then triggers the following c# code when selecting a row:
private void dgOrderOverview_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
{
        OverViewData r = (OverViewData)dgOrderOverview.SelectedItem;
        shipID = r.ShipmentID;
 
        lblSelectedReceiver.Content = r.ReceiverName;
        lblSelectedShipment.Content = shipID;
         
        if(dpStatusDate.SelectedDate == null)
            dpStatusDate.SelectedDate = DateTime.Now;
 
        tpStatusTime.Value = DateTime.Now;
        canvas1.Visibility = Visibility.Visible;
        lblCUselShipment.Content = r.ShipmentID;
}

However, when I select a row it the dgOrderOverview.SelectedItem is always null. If I look at it in the VS debugger I find that it says that SelectionEventArgs flags "remove" to the item I've selected, but the "added" is always null.

How come? This is new to me, it's been working since December before updating the RAD Controls for WPF.

//Johannes

2 Answers, 1 is accepted

Sort by
0
Johannes
Top achievements
Rank 1
answered on 17 Apr 2013, 08:07 AM
Please remove this. I saw that there was a method that was being called that set selecteditem to null later in the code. :P

My apologies.

//Johannes
0
Yoan
Telerik team
answered on 17 Apr 2013, 08:12 AM
Hi Johannes,

I am glad to hear that you have resolved the problem by yourself.

Please if you face any further difficulties do not hesitate to contact us.


Regards,
Yoan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Johannes
Top achievements
Rank 1
Answers by
Johannes
Top achievements
Rank 1
Yoan
Telerik team
Share this question
or