开发者

How to get custom message for ListView when there are no rows

I need to show "There are no records" message whe开发者_如何学JAVAn there are no rows for list view i want to show the message.

How can i do this?

Thanks.


Extending @Christian's answer:

Using code-bahind:

protected void ListView1_ControlRemoved (object sender, EventArgs e)
{
   var ListView1 = sender as ListView;
   if (ListVeew1.Items.Count == 0)
       ListView1.Items.Add("There are no records");
}

OR using markup:

<asp:ListView runat="server" ID="ListView1">
    <EmptyDataTemplate>
        There are no records
    </EmptyDataTemplate>
</asp:ListView>


Use the following markup:

<asp:ListView runat="server" ID="LstCustomer">
    <EmptyDataTemplate>
        Customer not found
    </EmptyDataTemplate>
</asp:ListView>


You don't say what you are programming in... But I believe the most common way to do this is to actually insert an item with the text "There are no records".

You can use the <EmptyDataTemplate> to specify what to display when the data source is empty.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜