ERROR=Cannot perform this operation when DataSource is not assigned.

3 posts, 0 answers
  1. Shawn
    Shawn avatar
    15 posts
    Member since:
    Jun 2014

    Posted 26 Feb 2015 Link to this post

    I am seeing an intermittent problem where users are getting the exception above when RadListView perfoms a DataBind. I am not sure how it can happen, because my code creates a data table and assigns it to the RadListView. Even if it failed to add anything to the data table, it wouldn't cause an exception. Could this be caused by one of the controls in the template?

    Here's the stack trace:
    ERROR=Cannot perform this operation when DataSource is not assigned. STACK TRACE= 
    at Telerik.Web.UI.ListViewNullEnumerable.get_DataSourceCount() 
    at Telerik.Web.UI.RadListView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) 
    at Telerik.Web.UI.RadListView.PerformDataBinding(IEnumerable data) 
    at System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) 
    at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) 
    at System.Web.UI.WebControls.DataBoundControl.PerformSelect() at Telerik.Web.UI.RadListView.PerformSelect() 
    at System.Web.UI.WebControls.BaseDataBoundControl.DataBind() at Telerik.Web.UI.RadListView.DataBind() 
    <my code..>

    Here's the HTML:

    <telerik:RadListView ID="RadListView1" runat="server" Width="100%" AllowPaging="true" ItemPlaceholderID="StylesHolder" DataKeyNames="StyleNumber" OnPageIndexChanged="RadListView1_PageIndexChanged">
            <fieldset style="width: 100%; border: none;" id="FieldSet1">
                <asp:Panel ID="StylesHolder" runat="server">
            <div class="grid_3 SearchResults_Container">
                <a href="#" onclick="DetailClick('<%# Eval("StyleNumber") %>')">
                    <%-- This div is necessary in that 'relative' is required in a div before 'absolute' is used in next dic --%>
                    <div class="SearchResults_ImageContainer">
                        <%-- This div forces image to be vertical-aligned at bottom, just above text, but centered. --%>
                        <div class="SearchResults_ImageAlignment">
                            <%# GetStylePrimaryImage(Eval("StyleNumber") as string) %>
                    <%# Eval("StyleNumber") %><br />
                    <%# Eval("ProductName") %>

    The CodeBehind looks like this:
            radListView.DataSource = GetDataTable(strCollectionID, strCollectionName, strDesignerID, strDesignerName, strProductTypeID, strProductTypeName, strRoomID, strRoomName, strSearch);
        public DataTable GetDataTable(string strCollectionID, string strCollectionName, string strDesignerID, string strDesignerName, string strProductTypeID, string strProductTypeName, string strRoomID, string strRoomName, string strSearch)
            DataTable dt = new DataTable();
    (Put some stuff in the table)
            return dt;
  2. Shawn
    Shawn avatar
    15 posts
    Member since:
    Jun 2014

    Posted 27 Feb 2015 Link to this post

    Sorry - this should be in the RadListView forum, not RadGrid. My mistake.
  3. Konstantin Dikov
    Konstantin Dikov avatar
    2409 posts

    Posted 03 Mar 2015 Link to this post

    Hello Snawn,

    Can you please refer to the answer in the other forum thread that you have opened with the same question:
    If any other questions arise, I suggest that we continue our communication in the other thread.

    Konstantin Dikov

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top