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

[Solved] Set CheckBox to TRUE/FLASE within RadGridViewDataColumn

2 Answers 102 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.
Mark
Top achievements
Rank 1
Mark asked on 07 Feb 2011, 01:01 PM
 Hi

I am newbie in using Silverlight/Telerik. I have Gridview with column Name and checkbox selection.
I want to manipulate the checkbox inside the gridview in codebehind of other controls like Button.

Something like the concept of code below

Private
Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnReset.Click

 

  For i = 0 to GridView.items.count - 1
         if (condition is valid) then
               GridView.items(i).columns(0).chkUser.Value = true
          else
               GridView.items(i).columns(0).chkUser.Value = true
        end if
   Next

End Sub

Moreover, I want to get the value of checkbox in cell rows.

Dim value as Boolean
value = GridView.items(i).columns(0).chkUser.value



Is anyone could help me with how I could do this?
Here is my XAML code below.

 

 

 

 

<telerik:RadGridView ItemsSource="{Binding Data, ElementName=UserDataSource}" Width="500" Grid.Row="1" Grid.ColumnSpan="2" RowIndicatorVisibility="Collapsed" Name="rdUser" CanUserSortColumns="False" ShowGroupPanel="False" EnableRowVirtualization="True" CanUserDeleteRows="True" CanUserFreezeColumns="False" CanUserInsertRows="False" CanUserReorderColumns="False" CanUserResizeColumns="False" CanUserSelect="True" BorderThickness="1" IsFilteringAllowed="False" IsReadOnly="False" ShowColumnHeaders="True" SelectionUnit="Cell" AutoGenerateColumns="False" GridLinesVisibility="None" HorizontalAlignment="Left" SelectionMode="Extended">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn>
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<Grid>
<CheckBox x:Name="chkUser" Height="16" IsChecked="False" />
</Grid>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
<telerik:GridViewDataColumn Header="Code" Width="150*" UniqueName="UserCode" DataMemberBinding="{Binding UserCode}" IsVisible="False" />
<telerik:GridViewDataColumn Header="Name" Width="150*" UniqueName="ItemName" DataMemberBinding="{Binding Name}" IsReadOnly="True" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>

 

2 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 07 Feb 2011, 01:11 PM
Hello Mark,

The recommended approach would be to expose a boolean property in your business object and bind it to the CheckBox property IsChecked. Afterwards you may change the checked/unchecked state of each CheckBox by getting the value of the exposed property for each item.
   

Best wishes,
Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Mark
Top achievements
Rank 1
answered on 08 Feb 2011, 02:59 AM
Hi Maya

It works. Thank you

Best wishes,

Mark Dumasig

Tags
GridView
Asked by
Mark
Top achievements
Rank 1
Answers by
Maya
Telerik team
Mark
Top achievements
Rank 1
Share this question
or