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:
The CodeBehind looks like this:
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;
}