RadComboBox loosing its value in postback

2 posts, 0 answers
  1. Manav
    Manav avatar
    3 posts
    Member since:
    Apr 2016

    Posted 27 Apr Link to this post

    I am using a RadComboBox inside RadGridColumn.   RadGrid is binded with a SQL Data Source.  and  RadCombobox is  also associated with a SQLDataSource. In the insert or edit more, It has a selected index changed method associated with it which in turn gives values to another dropdown (Cascades ).   This piece is working fine. 

    My problem starts when I try to insert or edit record.  Somehow the first radCombobox Looses its value and is always getting reset at first item while saving. !!

    Can you suggest why is this happening. 

    i have wasted hours in debugging and couldn't find the cause yet. !!

    Any help is appreciated.

      

      <Columns>            
                   <telerik:GridTemplateColumn DataField="ProviderName" HeaderText="ProviderName" UniqueName="ProviderName">
                       <ItemTemplate>
                           <asp:Label ID="lblProvider" runat="server" Text='<%#Eval("ProviderName")%>'></asp:Label>
                       </ItemTemplate>
                       <EditItemTemplate>
                           <telerik:RadComboBox ID="rcbProviders" runat="server" AutoPostBack="true" Text="Select Provider" DataSourceID="sqlGetAllProviders" 
                                DataTextField="ProviderName" DataValueField="ProviderID" OnSelectedIndexChanged="rcbProviders_SelectedIndexChanged" SelectedValue='<%# Eval("ProviderID")%>'></telerik:RadComboBox>
                       </EditItemTemplate>

                   </telerik:GridTemplateColumn>

     

     

    --Code for Selected index changed which cascades another drowdown

    Protected Sub rcbProviders_SelectedIndexChanged(sender As Object, e As RadComboBoxSelectedIndexChangedEventArgs)

            Dim editedItem As GridEditableItem = TryCast(TryCast(sender, RadComboBox).NamingContainer, GridEditableItem)
            Dim providerCombo As RadComboBox = TryCast(sender, RadComboBox)
            Dim programCombo As RadComboBox = TryCast(editedItem("ProgramName").FindControl("rcbPrograms"), RadComboBox)
            programCombo.DataSource = GetProgramsForSelectedProvider(e.Value)
            programCombo.DataBind()
        End Sub

    --Code to save the record

    Try
                Dim ddlProvider As RadComboBox = CType(e.Item.FindControl("rcbProviders"), RadComboBox)
                Dim ddlPrograms As RadComboBox = CType(e.Item.FindControl("rcbPrograms"), RadComboBox)
                Dim ddlLevel As RadComboBox = CType(e.Item.FindControl("rcbEducationLevel"), RadComboBox)
                Dim startDate As String = Request.Form(e.Item.FindControl("radStartDate").UniqueID)
                Dim endDate As String = Request.Form(e.Item.FindControl("radEndDate").UniqueID)
                Dim str As String = String.Empty

                
                EducationDetailsGE.SetValue("InstitutionID", ddlProvider.SelectedValue)
                EducationDetailsGE.SetValue("EducationFieldID", ddlPrograms.SelectedValue)
                EducationDetailsGE.SetValue("EducationLevelID", ddlLevel.SelectedValue)
                EducationDetailsGE.SetValue("StartDate", startDate)
                EducationDetailsGE.SetValue("EndDate", endDate)
                If PersonGE.Save(str) Then
                    LoadGrid()
                Else

                End If

            Catch ex As Exception

            End Try

  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1803 posts

    Posted 02 May Link to this post

    Hi Manav,

    The described behavior is not expected, unless you are rebinding your RadGrid on each postback, which could lead to resetting the values in the editors. With that in mind, could you please provide the entire markup of your RadGrid and the relevant part of the code-behind, so we can take a look at the implementation.

    On a side note, have in mind that having editors that initiate postback with Batch EditMode is not supported scenario and if you are using that edit mode, it is expected to lose the selected values.

    Looking forward to your reply.


    Regards,
    Konstantin Dikov
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top