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

RadComboBox loosing its value in postback

1 Answer 182 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Manav
Top achievements
Rank 1
Manav asked on 27 Apr 2016, 03:56 PM

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

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 02 May 2016, 08:56 AM
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.
Tags
Grid
Asked by
Manav
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or