I am linking a ListView with a collection of objects that work fine. Unfortunately, when the collection is empty, I do not get the text in the EmptyItemTemplate element as I expected.
Markup code
<asp:ListView ID="lvBuildingContactsGrid" runat="server" onitemcommand="lvBuildingContactsGrid_ItemCommand" > <LayoutTemplate> <asp:PlaceHolder ID="itemPlaceholder" runat="server" /> </LayoutTemplate> <ItemTemplate> </ItemTemplate> <EmptyItemTemplate> <p> empty text that isn't displaying </p> </EmptyItemTemplate> </asp:ListView>
The binding code is
ContactRoleCollection contactRoles = new ContactRoleCollection(); contactRoles.ContactRoleSearchByBuildingID(int params); lvListView.DataSource = contactRoles; lvListView.DataBind();
When the collection returns a zero count, the text EmptyItemTemplate is not displayed. I looked at the source of the page and it is not displayed at all (and not hiding). I replaced the DataSource object with only null ie
lvListView.DataSource = null
Just test it and it still doesn't work. The text is not displayed again.
I had this problem on other pages that I worked on (and did not work and did kludge work arounds), so this is clearly just what I am missing is wrong.
Any input is appreciated.
Crab bucket
source share