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

AJAX Postback issue with RadioButtonList?

4 Answers 123 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 04 Oct 2011, 02:27 PM
I have a RadioButtonList that gets its elements via a SqlDataSource
<asp:RadioButtonList ID="rblRadioButtons" runat="server" AutoPostBack="True" DataSourceID="ComboBoxDataSource"
    DataTextField="Name" DataValueField="ID" RepeatColumns="4" RepeatDirection="Horizontal">
</asp:RadioButtonList>

When I try to make on of the elements selected by default in the Page_Load (e.g. rblRadioButtons.SelectedValue = "2")

The bound RadComboBox in my insert/edit form (EditFormType="WebUserControl") doesn't change it's selection whenever the selected value = 2.
<telerik:RadComboBox ID="MealID" SelectedValue='<%# Bind("ID") %>' runat="server"
      DataSourceID="ComboBoxDataSource" DataTextField="Name" DataValueField="ID">
</telerik:RadComboBox>

So if the elements returned by ComboBoxDataSource are:

Name        ID
One           1
Two           2
Three        3
Four          4 

...when the RadioButtonList has a selected value of 2, the RadComboBox should show "Two" but it doesn't. However, if you select 1, 3, or 4, the radComboBox shows the right entry of "One, "Three", and "Four" respectively.

Also, I want to note, that if I comment out the RadAjaxManager, it works fine for all elements 1, 2, 3 and 4.

I hope this made sense and thanks for the help.

4 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 07 Oct 2011, 05:36 AM
Hi Chris,

What ajax settings you have? Can you share the whole page markup?

Greetings,
Iana Tsolova
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Chris
Top achievements
Rank 1
answered on 07 Oct 2011, 01:31 PM
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false"
    CodeFile="Default.aspx.vb" Inherits="Default" %>
 
<%@ MasterType VirtualPath="~/MasterPage.master" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <!-- custom head section -->   
    <!-- end of custom head section -->
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div style="width: 75%; padding: 20px 0 0 50px">
        <asp:HiddenField ID="HiddenField1" runat="server" />       
       <asp:RadioButtonList ID="rblRadioButtons" runat="server" AutoPostBack="True" DataSourceID="ComboBoxDataSource"
            DataTextField="Name" DataValueField="ID" RepeatColumns="4" RepeatDirection="Horizontal">
        </asp:RadioButtonList>
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
                function RowDblClick(sender, eventArgs) {
                    sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
                }
            </script>
        </telerik:RadCodeBlock>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="rblRadioButtons">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />                       
                    </UpdatedControls>
                </telerik:AjaxSetting>               
            </AjaxSettings>
        </telerik:RadAjaxManager>       
        <telerik:RadGrid ID="RadGrid1" GridLines="None" runat="server" AllowAutomaticDeletes="True"
            AllowAutomaticInserts="false" PageSize="10" AllowAutomaticUpdates="True" AllowPaging="True"
            AutoGenerateColumns="False" DataSourceID="GridViewDataSource" AllowSorting="true">
            <PagerStyle Mode="NextPrevAndNumeric" />
            <MasterTableView Width="100%" CommandItemDisplay="TopAndBottom" DataKeyNames="Main_ID"
                UseAllDataFields="true" DataSourceID="GridViewDataSource" HorizontalAlign="NotSet"
                AutoGenerateColumns="False">
                <Columns>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditColumn">
                        <ItemStyle CssClass="MyImageButton" />
                    </telerik:GridEditCommandColumn>
                    <telerik:GridBoundColumn DataField="Main_ID" UniqueName="Main_ID" HeaderText="ID" ReadOnly="true" Visible="false" />
                    <telerik:GridBoundColumn DataField="Name" HeaderText="Name" SortExpression="Name"
                        UniqueName="Name">
                    </telerik:GridBoundColumn>                   
                    <telerik:GridButtonColumn ConfirmText="Delete this?" ConfirmDialogType="RadWindow"
                        ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                        UniqueName="DeleteColumn">
                        <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                    </telerik:GridButtonColumn>
                </Columns>
                <EditFormSettings UserControlName="Insert.ascx" EditFormType="WebUserControl">                   
                </EditFormSettings>
                <CommandItemSettings AddNewRecordText="Add New?" RefreshText="Refresh Grid" />
            </MasterTableView>
            <ClientSettings>
                <ClientEvents OnRowDblClick="RowDblClick" />
            </ClientSettings>
        </telerik:RadGrid>
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
        </telerik:RadWindowManager>
        <br />
        <asp:SqlDataSource ID="GridViewDataSource" SelectCommand="procList" SelectCommandType="StoredProcedure"
             UpdateCommand="procUpdate"
            UpdateCommandType="StoredProcedure" DeleteCommand="procUpdate" DeleteCommandType="StoredProcedure"
            ConnectionString="<%$ AppSettings: DBConn %>" runat="server">
            <SelectParameters>
                <asp:Parameter Name="Main_ID" Type="Int32" DefaultValue="2" />
                <asp:ControlParameter Name="YearID" Type="Int32" DefaultValue="0" ControlID="HiddenField1"
                    PropertyName="Value" />
                <asp:Parameter Name="SortType" Type="String" DefaultValue="M" />
            </SelectParameters>           
            <UpdateParameters>
                <asp:Parameter Name="Main_ID" Type="Int32" />
                <asp:ControlParameter Name="YearID" Type="Int32" DefaultValue="0" ControlID="HiddenField1"
                    PropertyName="Value" />
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="ID" Type="Int32" />
                <asp:Parameter Name="Delete" Type="Boolean" DefaultValue="False" />
                <asp:Parameter Name="RetCode" Type="Int32" Direction="Output" />
                <asp:Parameter Name="RetMsg" Type="String" Direction="Output" Size="300" />
            </UpdateParameters>
            <DeleteParameters>
                <asp:Parameter Name="Main_ID" Type="Int32" />
                <asp:ControlParameter Name="YearID" Type="Int32" DefaultValue="0" ControlID="HiddenField1"
                    PropertyName="Value" />
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="ID" Type="Int32" />
                <asp:Parameter Name="Delete" Type="Boolean" DefaultValue="True" />
                <asp:Parameter Name="RetCode" Type="Int32" Direction="Output" />
                <asp:Parameter Name="RetMsg" Type="String" Direction="Output" Size="300" />
            </DeleteParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="ComboBoxDataSource" SelectCommand="procList" SelectCommandType="StoredProcedure"
            ConnectionString="<%$ AppSettings: DBConn %>" runat="server">
            <SelectParameters>
                <asp:ControlParameter Name="YearID" Type="Int32" DefaultValue="0" ControlID="HiddenField1"
                    PropertyName="Value" />
                <asp:Parameter Name="ByID" Type="Boolean" DefaultValue="True" />
                <asp:Parameter Name="ByName" Type="Boolean" DefaultValue="False" />
            </SelectParameters>
        </asp:SqlDataSource>
    </div>
</asp:Content>
0
Accepted
Iana Tsolova
Telerik team
answered on 09 Oct 2011, 06:53 PM
Hi Chris,

Try modifying the ajax settings as below and let me know if it makes any difference:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="rblRadioButtons">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                <telerik:AjaxUpdatedControl ControlID="rblRadioButtons" />
            </UpdatedControls>
        </telerik:AjaxSetting>               
    </AjaxSettings>
</telerik:RadAjaxManager>


Regards,
Iana Tsolova
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Chris
Top achievements
Rank 1
answered on 10 Oct 2011, 02:53 PM
Thanks Iana! That did the trick.
Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Chris
Top achievements
Rank 1
Share this question
or