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

Radgrid with Radio Button

1 Answer 61 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mani
Top achievements
Rank 1
Mani asked on 21 Aug 2014, 02:05 PM
Hello,

I am having issue with radio button selection on Radgrid...  I am initially setting Disabled checked on all rows in Markup....

in my code behind, I am trying to change selection and it is not working.....

Here is my Markup..


<telerik:RadGrid ID="gridMember" runat="server" ShowFooter="false" AutoGenerateColumns="False"
                        Skin="Metro" AllowPaging="False" ShowStatusBar="False" Width="700px"
                        OnNeedDataSource="gridMember_NeedDataSource" Height="600px" >
           
                    <GroupingSettings CaseSensitive="false" />
                    <MasterTableView DataKeyNames="UserName">
                      <Columns>                          <telerik:GridTemplateColumn HeaderText="Enable" ShowFilterIcon="false" Resizable="False">  
                                        <ItemTemplate> 
                                            <asp:RadioButton runat="server" ID="rdEnable" GroupName='{Binding UserName}' AutoPostBack="True" /> 
                                        </ItemTemplate> 
                               <HeaderStyle Width="35" />                                           
                          </telerik:GridTemplateColumn>                            <telerik:GridTemplateColumn HeaderText="Disable" ShowFilterIcon="false" Resizable="False">  
                                        <ItemTemplate> 
                                            <asp:RadioButton runat="server" ID="rdDisable" Checked="True" GroupName='{Binding UserName}' AutoPostBack="True" /> 
                                        </ItemTemplate>
                                <HeaderStyle Width="35" />                                            
                          </telerik:GridTemplateColumn>                          <telerik:GridBoundColumn ItemStyle-VerticalAlign="Top" UniqueName="Name" HeaderText="Name"
                            DataField="Name" >
                              <HeaderStyle Width="150" />    
                        </telerik:GridBoundColumn>                         <telerik:GridBoundColumn ItemStyle-VerticalAlign="Top" UniqueName="UserName" HeaderText="UserName"
                            DataField="UserName" >
                              <HeaderStyle Width="100" />    
                        </telerik:GridBoundColumn>                                        <telerik:GridBoundColumn UniqueName="IsActive" AutoPostBackOnFilter="true" CurrentFilterFunction="EqualTo"
                            ShowFilterIcon="false" CurrentFilterValue="True" HeaderText="Current Status" DataField="IsActive" > 
                             <HeaderStyle Width="75" />                              
                        </telerik:GridBoundColumn>                                                <telerik:GridButtonColumn ConfirmText="Delete this record?" ConfirmDialogType="RadWindow"
                            ConfirmTitle="Delete" ButtonType="ImageButton" HeaderText="Delete User" CommandName="Delete" Text="Delete"
                            UniqueName="DeleteColumn" ImageUrl="~/Images/Delete.gif"> 
                            <HeaderStyle Width="75" />                                              
                        </telerik:GridButtonColumn>                      </Columns>
                    </MasterTableView>                   <%-- <ClientSettings>
                         <Scrolling AllowScroll="true" ScrollHeight="500px" UseStaticHeaders="true"   />
                 </ClientSettings>--%>
                  </telerik:RadGrid>


-----------------------------------------------------

Code Behind:( i am trying to change the selection on Radgrid and it is not working....)  the below function is called after binding data to Radgrid....


Public Sub CheckFirmVerified(ByVal firmId As Integer)
Dim db As New MembershipDB
Dim memberUser As MembershipUser = Nothing
Dim _firm As FirmBO = FirmManager.getFirmListByFID(firmId)

If _firm IsNot Nothing Then

If _firm.Firm_Verified = "Yes" Then 'the firm is verified
'loop the grid and enable active users
For Each dataItem As GridDataItem In gridMember.MasterTableView.Items
Dim rbEnableSelected As RadioButton = CType(dataItem.FindControl("rdEnable"), RadioButton)

Dim userName As String = dataItem("UserName").Text 'get the username
memberUser = Membership.GetUser(userName) 'get the member user
If memberUser.IsApproved Then 'gets or sets whether the membership user can be authenticated.
'rbEnableSelected.Checked = True
CType(dataItem.FindControl("rdEnable"), RadioButton).Checked = True

End If
Next
End If
End If

End Sub




Any Idea?

Thanks

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 22 Aug 2014, 04:23 AM
Hi Mani,

I see that you are using two RadioButtons in your grid in two columns each. When one button is enabled the other button will be disabled, that's the default behavior of the RadioButtons. You have disabled the rdEnable, but checked the rdDisable, so inorder to have rdEnable checked you have to disable, rdDisable then set rdEnable checked, or you may have to use Checkbox control instead of radio button.

Thanks,
Shinu
Tags
Grid
Asked by
Mani
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or