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

10 posts, 0 answers
  1. Shawn
    Shawn avatar
    14 posts
    Member since:
    Jun 2014

    Posted 26 Feb 2015 Link to this post

    I am getting this exception intermittently when binding a RadListView. I create a data table, fill it with some data, assign it as the data source, and then do a data bind. I know the code always returns a data table, even if it is empty, so this error can't be caused by a null data source. Could it be caused by something else, maybe one of the fields in the item template?

    Here's the 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() 

    Here's my HTML code:
    <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>
  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 03 Mar 2015 Link to this post

    Hello Shawn,

    From the provided code snippet only it would be impossible for us to determine what is causing the issue on your end. 

    However, since you are not handling the OnNeedDataSource event, I could only assume that you are using Simple Data-Binding, can you please confirm that you are wrapping the DataBind method within the Page's Load event handler in !Page.IsPostback condition, as demonstrated in the example in the help article?

    You could also try to use Advanced Data-Binding by handling only the OnNeedDataSource event of the RadListView control.

    If you continue to experience problems with this, please open a regular support ticket with an attached sample, runnable project replicating the issue. 


    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Shawn
    Shawn avatar
    14 posts
    Member since:
    Jun 2014

    Posted 03 Mar 2015 in reply to Konstantin Dikov Link to this post

    The bind can occur on page load, or from user interaction. The page allows the user to search for particular items, so the DB query is made according to user selections. The code looks like this:
    radListView.DataSource = GetDataTable(strCollectionID, strCollectionName, strDesignerID, strDesignerName, strProductTypeID, strProductTypeName, strRoomID, strRoomName, strSearch);
    radListView.DataBind();

    The GetDataTable returns a DataTable that is filled in from a SQL query. Even if the data table is empty the function runs ok, so I can't figure out what is causing this exception. It only happens occasionally when people browse the site. I have been unable to reproduce myself, either locally or on the live site. I am wondering if the problem might be caused by a user clicking something before the page is fully loaded, although they shouldn't be able to do that. Or maybe it happens when the web page doesn't fully load?
  5. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 06 Mar 2015 Link to this post

    Hi Shwan,

    Do you have the exception message? Having the exception message in combination with the stack trace
    could help us in isolating the cause of it. Additionally, please share any information that you have on the scenario when the error is observed by the users.

    I am looking forward to your reply.


    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.

     
  6. Shawn
    Shawn avatar
    14 posts
    Member since:
    Jun 2014

    Posted 09 Mar 2015 in reply to Konstantin Dikov Link to this post

    The exception message is the title of this post. We log the entire message in our database. That's why we know this is occurring. Here is the entire message:

    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()
       at LookupStyles.BindListViewToDataSource(RadListView radListView, String strCollectionID, String strCollectionName, String strDesignerID, String strDesignerName, String strProductTypeID, String strProductTypeName, String strRoomID, String strRoomName, String strSearch) in c:\A-IISApps\VanguardFurniture.com\CFWebsite-v2.10\pages\LookupStyles.aspx.cs:line 441
       at LookupStyles.UpdateSearchData() in c:\A-IISApps\VanguardFurniture.com\CFWebsite-v2.10\pages\LookupStyles.aspx.cs:line 662
       at LookupStyles.RadListView1_PageIndexChanged(Object sender, RadListViewPageChangedEventArgs e) in c:\A-IISApps\VanguardFurniture.com\CFWebsite-v2.10\pages\LookupStyles.aspx.cs:line 641
       at Telerik.Web.UI.RadListView.OnPageIndexChanged(RadListViewPageChangedEventArgs e)
       at Telerik.Web.UI.RadListView.SetPageProperties(Int32 startRowIndex, Int32 maximumRows, Boolean databind)
       at Telerik.Web.UI.RadListView.Telerik.Web.UI.IRadPageableItemContainer.SetPageProperties(Int32 startRowIndex, Int32 maximumRows, Boolean databind)
       at Telerik.Web.UI.RadDataPager.ApplySettingsOnContainer(Int32 startRowIndex, Int32 pageSize, Boolean shouldBind)
       at Telerik.Web.UI.RadDataPager.CallCommandToContainer(String commandName, String commandArgument)
       at Telerik.Web.UI.RadDataPager.OnBubbleEvent(Object source, EventArgs args)
       at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
       at Telerik.Web.UI.RadDataPagerFieldItem.OnBubbleEvent(Object source, EventArgs args)
       at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
       at System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e)
       at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 

  7. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 12 Mar 2015 Link to this post

    Hello Shawn,

    Based on he information provided till now it is rather difficult to determine what exactly is causing the issue. Can you please elaborate if the DataBinding mechanism is used on each post back and if the RadListView has valid DataSource assigned on each post. Also this error may appear in case you are setting null ad DataSource for the RadLisdtView.
    It will be best if you can open a regular support ticket and send us sample runnable application that demonstrates the issue. Thus we will be able to debug it locally and advise you further.

    Regards,
    Maria Ilieva
    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.

     
  8. Shawn
    Shawn avatar
    14 posts
    Member since:
    Jun 2014

    Posted 12 Mar 2015 in reply to Maria Ilieva Link to this post

    As I said before, it is sporadic. I haven't seen it myself. I just see it occasionally occur in our error logs. 
    Concerning the datasource: The RadListView is rebound depending on user interaction. It is on a screen that allows users to browse products. The RLV is rebound manually on postback if the user changes filters or goes to a new page in the results. Some other interactions which cause postback may not cause a rebind. But the code which does a rebind always assigns a data source, a DataTable, although it is possible that the table will be empty if there are no results. 
  9. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 17 Mar 2015 Link to this post

    Hello Shawn,

    Note that without having an option to replicate the issue and debug the application locally it would be rather difficult to isolate what exactly is causing this error.
    You can post the whole page markup and related code behind here, so that we can research on them and see if any obvious reason can be isolated from the code.


    Regards,
    Maria Ilieva
    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.

     
  10. Shawn
    Shawn avatar
    14 posts
    Member since:
    Jun 2014

    Posted 17 Mar 2015 in reply to Maria Ilieva Link to this post

    Unfortunately I can't post the entire page. It is rather large and complicated, and relies on a lot of libraries we have developed. I will work on trying to figure out how to reproduce the error.
  11. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 19 Mar 2015 Link to this post

    Hi,

    If you succeed in reproducing the error in isolated project, you can open a regular support ticket and send the project to us. Thus we will be able to debug it locally and advise you further.

    Regards,
    Maria Ilieva
    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
UI for ASP.NET Ajax is Ready for VS 2017