Display message and header when Gridview is empty in asp.net - ASPMANTRA | Asp.Net,MVC,AngularJs,Jquery,Javascript,Sql Server AND WCF snippets and tutorial

Display message and header when Gridview is empty in asp.net

Introduction: In this article I will explain how we can Display message and header when Gridview is empty.


In application we have to show the header and empty message when there no data in table. We can show that via code behind or use the Gridview property.  Easiest way to do this is use the Gridview control property. We have set only two property for this EmptyDataText and showHeaderWhenEmpty. See the given example below:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"
            EmptyDataText="No data Found" ShowHeaderWhenEmpty ="true">    
        <asp:BoundField DataField="emp_name" HeaderText="Employee Name"/>
         <asp:BoundField DataField="emp_adress" HeaderText="Address" />
          <asp:BoundField DataField="emp_salary" HeaderText="Salary" />     

Is this article helpful for you?

If yes post your comment to appreciate my work and fell free to contact me. You can like me on Facebook, Google+, Linkedin and Twitter via hit on Follow us Button and also can get update follow by Email. 

What do you think about this article?

If you found this article useful, please share and follow on Facebook, Twitter, Google Plus and other social media websites. To get free updates subscribe to newsletter. Please put your thoughts and feedback in comments section.