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

RadComboBox datasource empty on postback

1 Answer 114 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Craig asked on 21 May 2012, 07:28 PM

I am assigning a radcombobox's datasource property a List(of Person) and then databinding it.  I have the Autopost property set to true so when a selection is made it will post back.  Unfortunately, the radcombobox's datasource property is nothing when the postback occurs.  Is there something I need to do to keep the datasource from being left to nothing?  Since I can't attach a zip file I am providing code snippets.
Imports Telerik.Web.UI
Imports System.Linq
Partial Class _Default
    Inherits System.Web.UI.Page
    Private Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            Dim people = {New Person With {.Name = "Craig", .UserId = "Wil1"}, New Person With {.Name = "Kaitlyn", .UserId = "Wil2"}, New Person With {.Name = "Ben", .UserId = "Wil3"}}.ToList
            radCbo.DataTextField = "Name" : radCbo.DataValueField = "UserId"
            radCbo.DataSource = people
        End If
    End Sub
    Private Sub radCbo_SelectedIndexChanged(sender As Object, e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles radCbo.SelectedIndexChanged
        Dim ds = radCbo.DataSource
        Dim i = radCbo.SelectedItem.DataItem
    End Sub
End Class
Public Class Person
    Public Property Name As String
    Public Property UserId As String
End Class

<%@ Page Language="VB" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="RadControlsWebAppComboTest._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<head runat="server">
    <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <%--Needed for JavaScript IntelliSense in VS2010--%>
            <%--For VS2008 replace RadScriptManager with ScriptManager--%>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
    <script type="text/javascript">
        //Put your JavaScript code here.
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <telerik:RadComboBox runat="server" ID="radCbo" AutoPostBack="true" EnableViewState="true"></telerik:RadComboBox>

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 22 May 2012, 02:56 PM
Hello Craig,

Take a look at the following forum threads discussing the issues you experience:

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.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question