Handle RadioButton event in edit mode

3 posts, 0 answers
  1. Roberto Wenzel
    Roberto Wenzel avatar
    37 posts
    Member since:
    Sep 2012

    Posted 23 Feb 2009 Link to this post

    Hello guys.
    In my data grid edit form i have a RadioButtonList (which is not binded to a grid column!) and a radUpload control which is disabled by default.
    I would like to have this radUpload control beeing enabled depending on the selected radio button.
    I mean: the user selects an option and depending on his choose the radUpload control is enabled or disabled immediately.
    Which settings do i have to make in the AJAX Manager? Where to handle the event in my VB ocde? How to update the edit form?
    Any help is appreciated.
    Cheers Roberto

                                    <asp:Label runat="server"  ID="lblFileName" Text="Attached file: "></asp:Label>
                                    <asp:Label ID="lblFileNameValue" runat="server" Text='<%# Eval("File name") %>'></asp:Label>
                                        <asp:RadioButtonList  ID="RadioButtonList1" runat="server" Font-Names="Arial" Font-Size="Small" RepeatDirection="Horizontal" AutoPostBack="True">
                            <asp:ListItem Selected="True">Keep file</asp:ListItem>
                            <asp:ListItem>Replace file</asp:ListItem>
                            <asp:ListItem>Delete file</asp:ListItem>
                                        <telerik:RadUpload ID="FileUpload" runat="server" Font-Size="Small" Enabled="false"
                                            InitialFileInputsCount="1" MaxFileInputsCount="1" Skin="Sunset" Width="400">
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 23 Feb 2009 Link to this post

    Hello Roberto,

    Try accessing the RadUpload in the SelectedIndexChanged event of the RadioButtonList and set it enabled/disabled according to the RadioButtonList text. To understand better check out the code below:
    protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)  
            RadioButtonList radbtnlist = (RadioButtonList)sender;  
            GridEditableItem editItem = (GridEditableItem)radbtnlist.NamingContainer;  
            RadUpload rdupload= (RadUpload)editItem.FindControl("FileUpload");  
            string strtxt = radbtnlist.Text;  
            if (strtxt == "Replace file")  
                rdupload.Enabled = true;  
                rdupload.Enabled = false;  

  3. DevCraft R3 2016 release webinar banner
  4. Roberto Wenzel
    Roberto Wenzel avatar
    37 posts
    Member since:
    Sep 2012

    Posted 23 Feb 2009 Link to this post

    that's it. Thanks a lot.
    Here is my code in VB.
    I added  ...OnSelectedIndexChanged="RadioChanged".. in ASPX for the RadioButtonList and the following code.

        Public Sub RadioChanged(ByVal sender As Object, ByVal e As EventArgs)
            Dim radbtnlist As RadioButtonList = sender
            Dim editItem As GridEditableItem = CType(CType(sender, RadioButtonList).NamingContainer, GridEditableItem)
            Dim radup As RadUpload = editItem.FindControl("FileUpload")
            Dim stext As String = radbtnlist.Text
            If stext = "Replace file" Then
                radup.Enabled = True
                radup.Enabled = False
            End If
    End Sub
Back to Top