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

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

2 Answers 98 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Shawn
Top achievements
Rank 1
Shawn asked on 26 Feb 2015, 10:26 PM
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 Answers, 1 is accepted

Sort by
0
Shawn
Top achievements
Rank 1
answered on 27 Feb 2015, 01:58 PM
Sorry - this should be in the RadListView forum, not RadGrid. My mistake.
0
Konstantin Dikov
Telerik team
answered on 03 Mar 2015, 01:19 PM
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.

 
Tags
ListView
Asked by
Shawn
Top achievements
Rank 1
Answers by
Shawn
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or