How to select checkbox from code behind

1 posts, 0 answers
  1. IT
    IT avatar
    1 posts
    Member since:
    Feb 2014

    Posted 20 Feb 2014 Link to this post


    I am new to Silverlight and Grid as well but have experince in C#. I have one grid that you can see in Pic.  I have one hardCoded method like GetHardCodedList that I am assining to ItemSource. 

    Grid has one checkbox column as well. I want that if returned is 1 then checkbox must be selected. If returned is zero then checkbox should not be selected. 

    Here is C# Code

     public List<Members.> GetHardCodedList()
                List<Members.> list = new List<Members.>();
                list.Add(new Members.() { Id = 1, Name = "Opus", Address = " India", OrgNo = "123456-78910", CompanyName = "ABC",Returned="0" });
                list.Add(new Members.() { Id = 1, Name = "Adam", Address = " Gustav Arnolds Gata 12, C", OrgNo = "123456-78910", CompanyName= "ABC", Returned="1" });
                list.Add(new Members.() { Id = 1, Name = "Tendulkar", Address = " Bumbai", OrgNo = "123456-78910", CompanyName= "ABC", Returned="1" });
                 return list;
     DataGridMembers.ItemsSource = _listMembers;    

    Here is XML.

      <rad:RadGridView  Name="DataGridMembers" AutoGenerateColumns="False" Background="#FFFFFF" Grid.Row="2" 
                Grid.Column="1" Margin="8,18,0,0"  IsFilteringAllowed="True" IsSynchronizedWithCurrentItem="True"
                GroupPanelBackground="White" GroupPanelForeground="White" VerticalAlignment="Top"
                Height="455" Grid.RowSpan="2">
                    <rad:GridViewDataColumn UniqueName="Returned" Header="Retur"  DataMemberBinding="{Binding IsActive}" IsReadOnly="True">
                                <CheckBox IsChecked="{Binding IsActive, Mode=TwoWay}"/>

                    <rad:GridViewDataColumn UniqueName="Id"   Header="#" Width="Auto" DataMemberBinding="{Binding Id, Mode=TwoWay}"/>
                    <rad:GridViewDataColumn UniqueName="OrgNo"   Header="OrgNo"  Width="Auto" DataMemberBinding="{Binding OrgNo, Mode=TwoWay}"/>
                    <rad:GridViewDataColumn UniqueName="CompanyName"   Header="Company Name"  Width="Auto" DataMemberBinding="{Binding CompanyName, Mode=TwoWay}"/>
                    <rad:GridViewDataColumn UniqueName="SignatureStatus"  Header="Signature Status"  Width="Auto" DataMemberBinding="{Binding SignatureStatus, Mode=TwoWay}"/>
                    <rad:GridViewDataColumn UniqueName="Name"  Header="(VD)"  Width="Auto" DataMemberBinding="{Binding Name, Mode=TwoWay}"/>
                    <rad:GridViewDataColumn UniqueName="Address"  Header="Adress"  Width="Auto" DataMemberBinding="{Binding Address, Mode=TwoWay}"/>
                    <rad:GridViewDataColumn UniqueName="City"  Header="City"  Width="Auto" DataMemberBinding="{Binding City, Mode=TwoWay}"/>
                    <rad:GridViewDataColumn UniqueName="ZipCode"  Header="ZipCode"  Width="Auto" DataMemberBinding="{Binding ZipCode, Mode=TwoWay}"/>
                    <!--<rad:GridViewDataColumn UniqueName="Returned"  Header="Retur"  Width="Auto" DataMemberBinding="{Binding Returned, Mode=TwoWay}"/>-->
                    <rad:GridViewDataColumn UniqueName="Description"  Header="Description"  Width="Auto" DataMemberBinding="{Binding Description, Mode=TwoWay}"/>

            </rad:RadGridView >     
    I dont know how to control my checkbox in grid with the help of returned value. This grid will use for editing purpose as well. Editing is working for text but I want that if user select any other check box then it will also update. 

    I have googled a lot but not getting proper answer. Any help please.


Back to Top