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

3 posts, 0 answers
  1. Shawn
    Shawn avatar
    14 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">
        <LayoutTemplate>
            <fieldset style="width: 100%; border: none;" id="FieldSet1">
                <asp:Panel ID="StylesHolder" runat="server">
                </asp:Panel>
            </fieldset>
        </LayoutTemplate>
        <ItemTemplate>
            <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) %>
                        </div>
                    </div>
                    <%# Eval("StyleNumber") %><br />
                    <%# Eval("ProductName") %>
                </a>
            </div>
        </ItemTemplate>
    </telerik:RadListView>

    The CodeBehind looks like this:
            radListView.DataSource = GetDataTable(strCollectionID, strCollectionName, strDesignerID, strDesignerName, strProductTypeID, strProductTypeName, strRoomID, strRoomName, strSearch);
            radListView.DataBind();
     
    ...
     
        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
    14 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. UI for ASP.NET Ajax is Ready for VS 2017
  4. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1795 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.


    Regards,
    Konstantin Dikov
    Telerik
     

    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