Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
if the data is not there in data base how to keep message no records found in list view binding.
Posted

Use ListView.EmptyDataTemplate Property[^].
Quote:

ASP.NET
<EmptyDataTemplate>
      <table class="emptyTable" cellpadding="5" cellspacing="5">
        <tr>
          <td>
            <asp:Image ID="NoDataImage"
              ImageUrl="~/Images/NoDataImage.jpg" 
              runat="server"/>
          </td>
          <td>
            No records available.
          </td>
        </tr>
      </table>
</EmptyDataTemplate>
 
Share this answer
 
v2
hi !!! try this

C#
protected void ListView1_ControlRemoved (object sender, EventArgs e)
{
   var ListView1 = sender as ListView;
   if (ListVeew1.Items.Count == 0)
       ListView1.Items.Add("no record found");
}



and in markup you use
XML
<EmptyDataTemplate>
         no record found
    </EmptyDataTemplate>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900