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

Handle RadioButton event in edit mode

2 Answers 76 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Roberto Wenzel
Top achievements
Rank 2
Roberto Wenzel asked on 23 Feb 2009, 08:19 AM
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

 <EditItemTemplate>
                                <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>
        </asp:RadioButtonList>
                                    <telerik:RadUpload ID="FileUpload" runat="server" Font-Size="Small" Enabled="false"
                                    AllowedFileExtensions=".zip,.pdf,.txt,.rtf,.jpg,.bmp,.tif,.rar"
                                    ControlObjectsVisibility="RemoveButtons"
                                        InitialFileInputsCount="1" MaxFileInputsCount="1" Skin="Sunset" Width="400">
                                    </telerik:RadUpload>
                                                                        
                                </EditItemTemplate>

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Feb 2009, 09:36 AM
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:
cs:
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;  
        }  
        else  
        {  
            rdupload.Enabled = false;  
        }  
    }  

Thanks
Princy.
0
Roberto Wenzel
Top achievements
Rank 2
answered on 23 Feb 2009, 11:42 AM
Hello,
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
        Else
            radup.Enabled = False
        End If
End Sub
Tags
Grid
Asked by
Roberto Wenzel
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Roberto Wenzel
Top achievements
Rank 2
Share this question
or