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

[Solved] Q3 2009 SP1 - GridView SelectedItems.count

1 Answer 66 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Bryan Spann
Top achievements
Rank 1
Bryan Spann asked on 16 Dec 2009, 12:19 AM
Hello,

I am kind of stumped over this issue I have been scouring your boards in hope of finding a resovle, but nothing has revealed itself.

I have a fairly standard grid, the client picks and item or two and then clicks a button, I do count check and display a message, however everytime I go to do this "RadGridView1.SelectedItems.Count" always equals 0 no matter how many I pick or dont pick.  Everything else about the grid seems to be working ok.

Any help would be extremely grateful.

<

 

UserControl x:Class="IDUser.IDUser"

 

 

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

 

 

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

 

 

xmlns:Controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"

 

 

xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"

 

 

xmlns:input="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input"

 

 

xmlns:grid="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView">

 

 

 

<Grid x:Name="LayoutRoot">

 

 

 

    <Grid.RowDefinitions>

 

 

 

        <RowDefinition Height="*"/>

 

 

 

        <RowDefinition Height="Auto"/>

 

 

 

    </Grid.RowDefinitions>

 

 

 

    <StackPanel Grid.Row="0">

 

 

 

        <Controls:RadGridView

 

 

            x:Name="RadGridView1"

 

 

            ItemsSource="{Binding}"

 

 

            SelectionMode="Multiple"

 

 

            MultipleSelect="True"

 

 

            IsReadOnly="True"

 

 

            AutoGenerateColumns="False"    

 

 

            UseAlternateRowStyle="True">

 

 

 

        <Controls:RadGridView.Columns>

 

 

 

            <Controls:GridViewSelectColumn/>

 

 

 

            <Controls:GridViewDataColumn>

 

 

 

                <Controls:GridViewDataColumn.Header>

 

 

 

                    <Grid>    

 

 

 

                        <Grid.RowDefinitions>

 

 

 

                            <RowDefinition />

 

 

 

                        </Grid.RowDefinitions>

 

 

 

                        <Grid.ColumnDefinitions>

 

 

 

                            <ColumnDefinition />

 

 

 

                            <ColumnDefinition />

 

 

 

                            <ColumnDefinition />

 

 

 

                        </Grid.ColumnDefinitions>

 

 

 

                        <TextBlock Width="150" Text="User" Grid.Column="0" Grid.Row="0" />

 

 

 

                        <TextBlock Width="150" Text="Account #" Grid.Column="1" Grid.Row="0" />

 

 

 

                        <TextBlock Width="150" Text="Item" Grid.Column="2" Grid.Row="0" />

 

 

 

                    </Grid>

 

 

 

                </Controls:GridViewDataColumn.Header>

 

 

 

                <Controls:GridViewDataColumn.CellTemplate>

 

 

 

                    <DataTemplate>

 

 

 

                        <Grid>

 

 

 

                            <Grid.RowDefinitions>

 

 

 

                                <RowDefinition />

 

 

 

                                <RowDefinition />

 

 

 

                            </Grid.RowDefinitions>

 

 

 

                            <Grid.ColumnDefinitions>

 

 

 

                                <ColumnDefinition />

 

 

 

                                <ColumnDefinition />

 

 

 

                                <ColumnDefinition />

 

 

 

                            </Grid.ColumnDefinitions>

 

 

 

                            <TextBlock Width="150" Text="{Binding CLIENT}" Grid.Row="0" Grid.Column="0" />

 

 

 

                            <TextBlock Width="150" Text="{Binding ACCTNO}" Grid.Row="0" Grid.Column="1" />

 

 

 

                            <TextBlock Width="150" Text="{Binding ITEM}" Grid.Column="2" Grid.Row="0" />

 

 

 

                        </Grid>

 

 

 

                    </DataTemplate>

 

 

 

                </Controls:GridViewDataColumn.CellTemplate>

 

 

 

            </Controls:GridViewDataColumn>

 

 

 

        </Controls:RadGridView.Columns>

 

 

 

    </Controls:RadGridView>

 

 

 

    </StackPanel>
    <StackPanel Height="30" Grid.Row="1" Orientation="Horizontal"  HorizontalAlignment="Left" Margin="0  0 0 15">
            <telerik:RadButton 
                        Click="Ok_Click" 
                        x:Name="Ok" 
                        Content="Ok" 
                         Width="100" 
                        Height="20" 
                        HorizontalContentAlignment="Center" 
                        VerticalContentAlignment="Center" 
                        Margin="300 0 50 0"/>
    

 

 

 

</StackPanel>

 

 

 

</Grid>

 

</

 

UserControl>

 

 

Private Sub Ok_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)

 

 

If RadGridView1.SelectedItems.Count > 1 Then

 

 

 

 

 

    Dim newmessage As String = "User has selected more than one"
ElseIf RadGridView1.SelectedItems.Count = 0 Then

 

 

 

 

 

    Dim newmessage As String = "User has selected Nothing"
Else

 

 

   Dim newmessage As String = "User has selected an item"
End
If

 

 

 

 

 

End Sub

 

 

 

1 Answer, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 18 Dec 2009, 09:20 AM
Hello Bryan Spann,

This is a very strange problem that we were unable to reproduce. Is it possible to send us a working application that will allow us to reproduce the problem? Sorry for the inconvenience.


Sincerely yours,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Bryan Spann
Top achievements
Rank 1
Answers by
Milan
Telerik team
Share this question
or