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

RadComboBox lose items on PostBack

3 Answers 295 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jesus
Top achievements
Rank 1
Jesus asked on 26 Jul 2013, 05:35 PM
Hi,

Here is the situation: I have a RadComboBox (not LoadOnDeman) which is filled with values when I load the page:

<telerik:RadComboBox ID="drpCollectingScript" runat="server" Height="150px" Width="225px"
DropDownWidth="360px" HighlightTemplatedItems="true" Filter="Contains" AutoPostBack="False"
MarkFirstMatch="true" OnClientKeyPressing="setHighlightedItem"
OnClientBlur="setId" OnClientFocus="toggleRadCombo" ViewStateMode="Enabled">
  <HeaderTemplate>
    <table style="width: 340px" cellspacing="0" cellpadding="0">
      <tr>
        <td style="width: 340px;">
          <asp:Label ID="lblCSCode" runat="server">Code</asp:Label>
        </td>
      </tr>
    </table>
  </HeaderTemplate>
  <ItemTemplate>
    <table style="width: 340px" cellspacing="0" cellpadding="0">
      <tr>
        <td style="width: 340px;">
          <%# DataBinder.Eval(Container, "Attributes['Code']")%>
        </td>
      </tr>
    </table>
  </ItemTemplate>
</telerik:RadComboBox>

CodeBehind:

If Me.IsPostBack = False Then
  Dim scripts = New CatalogService().GetAllScriptTips()
  For i As Integer = 0 To scripts.Count - 1
    Dim item As New RadComboBoxItem()
    item.Text = scripts(i).Code
    item.Value = scripts(i).ScriptTipId
 
    item.Attributes.Add("Code", scripts(i).Code)
    item.Attributes.Add("Script", scripts(i).ContentDesign)
    drpCollectingScript.Items.Add(item)
    item.DataBind()
  Next
End If

The problem is that if I don't make a Postback that refreshes the table element in which the RadComboBox is contained (using RadAjaxManager) within aproximately 2 minutes after loading the page, then the RadComboBox loses all of its items and this problem extends aswell to the asp:DropDownList controls which are contained within the same table element.

So, what's the problem here? What can I do to solve this problem?

3 Answers, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 31 Jul 2013, 11:31 AM
Hello Arturo,

I tried to replicate the described issue, but to no avail. I had prepared a sample page for you, demonstrating the behavior at my end. Would you give it a try at your end and let me know if I had missed something. Please find the attachment.

Regards,
Nencho
Telerik
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 the blog feed now.
0
Jacob
Top achievements
Rank 1
answered on 06 Aug 2015, 02:45 AM

I'm having exactly the same issue that I can consistently reproduce.

 I looked at your code...

Can you please explain this line: item.DataBind()?

 Are you calling DataBind() method on RadComboBoxItem?

0
Ivan Danchev
Telerik team
answered on 10 Aug 2015, 02:09 PM
Hello Arturo,

The DataBind() method is called on the RadComboBoxItems so that the Template can use the custom attributes in its data-binding expressions. 

Were you able to reproduce the issue in the sample project my colleague Nencho attached in his previous reply? If you were, could you please post your modifications so we can further investigate the reason for the observed behavior?

Regards,
Ivan Danchev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
ComboBox
Asked by
Jesus
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Jacob
Top achievements
Rank 1
Ivan Danchev
Telerik team
Share this question
or