ListView LayoutTemplate not showing when asp.net is empty

I have <asp:ListView>, but for some reason, the LayoutTemplate section is not displayed when the list is empty, although the section is <EmptyDataTemplate>shown. The LayoutTemplate contains the headers for the table, and I want to show an empty table when there are no elements in the data source, not just the contents of the EmptyDataTemplate.

If there is no choice, I will copy the LayoutTemplate to the EmptyDataTemplate, but it seems silly to do it. Ideas?

+5
source share
3 answers

From MSDN :

ListView , , InsertItemPosition InsertItemPosition.None. LayoutTemplate. InsertItemPosition , InsertItemPosition.None, EmptyDataTemplate .

"... LayoutTemplate...

, , LayoutTemplate EmptyDataTemplate.

+12

(.acsx). ... , . , ... , - 5- . - .

0

, , .

LayoutTemplate :

<LayoutTemplate>
  <table>
    <tr>
      <td>a header</td>
      <td>another header</td>
      <td>third header</td>
    </tr>
    <tr runat="server" id="itemPlaceholder">
      <td colspan="3"
        There is no data!
      </td>
    </tr>
  </table>
</LayoutTemplate>

, tr, ( id = "itemPlaceholder" ), -. , , . , , <EmptyTemplate> <LayoutTemplate> ( ). :

Private Sub lvwThings_Init(sender As Object, e As EventArgs) Handles lvwThings.Init
    lvwThings.EmptyDataTemplate = lvwThings.LayoutTemplate
End Sub

:

, .. <LayoutTemplate>, <tr runat="server" id="itemPlaceholder"> td , , <ItemTemplate>.

, .. <EmptyTemplate> ( <LayoutTemplate>), <EmptyTemplate> , .

0

All Articles