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

How to access the value of radiobutton selected

2 Answers 353 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ida
Top achievements
Rank 1
Ida asked on 23 Oct 2013, 03:31 PM
Hi,

Please could someone advise as to how to access the value of radiobutton selected.

This is the radiobuttonlist:

<telerik:GridTemplateColumn UniqueName="ShotEastWest" ColumnEditorID="ShotEastWest" HeaderText="Shot East/West" Visible="false">
                           <ItemTemplate>
                               <%# Eval("ShotEW")%>
                           </ItemTemplate>
                           <EditItemTemplate>
                               <asp:RadioButtonList ID="rdShotEastWest" runat="server" RepeatDirection="Horizontal">
                                   <asp:ListItem Text="East" Value="1"></asp:ListItem>
                                   <asp:ListItem Text="West" Value="2"></asp:ListItem>
                               </asp:RadioButtonList>
                           </EditItemTemplate>
                       </telerik:GridTemplateColumn>

I think the VB.NET I am using is wrong:

Dim radioShotEastWest As RadioButtonList = TryCast(edit("ShotEastWest").Controls(0), RadioButtonList)
Dim ShotEastWest As Integer = radioShotEastWest.SelectedValue


Thanks, Ida

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 Oct 2013, 04:48 AM
Hi Ida,

Please try the following code snippet to access the ButtonList selected value in UpdateCommand event.

VB:
Protected Sub RadGrid1_UpdateCommand(sender As Object, e As GridCommandEventArgs)
    If TypeOf e.Item Is GridEditableItem Then
        Dim edit As GridEditableItem = DirectCast(e.Item, GridEditableItem)
        Dim list As RadioButtonList = DirectCast(edit.FindControl("rdShotEastWest"), RadioButtonList)
        'Get the Value of selected item
        Dim val As Integer = Convert.ToInt32(list.SelectedValue)
        ' Get the Text of selected item
        Dim text As String = list.SelectedItem.Text
    End If
End Sub

Thanks,
Princy
0
Ida
Top achievements
Rank 1
answered on 24 Oct 2013, 08:10 AM
Brilliant! Many thanks Princy!
Tags
Grid
Asked by
Ida
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Ida
Top achievements
Rank 1
Share this question
or