Introduction: In
this article I will explain how we can Display message and header when Gridview
is empty.
Description:
In the previous article I have explained Fill dropdownlist with days, month and year in asp.net,Server side validation in MVC Razor using data annotation,Like linq query example and bind gridview,Create a dynamic Slider in asp.net, URL routing in asp.net website, Populate Dropdown List dynamically using Asp.net MVC Razor, Code First migration in asp.net MVC 4, Populate Cascading Dropdown List in Asp.net MVC4 using Json and Jquery and What is Asp.net MVC? Its advantages and disadvantges.
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">
<Columns>
<asp:BoundField DataField="emp_name"
HeaderText="Employee
Name"/>
<asp:BoundField DataField="emp_adress"
HeaderText="Address"
/>
<asp:BoundField DataField="emp_salary"
HeaderText="Salary"
/>
</Columns>
</asp:GridView>
No comments:
Post a Comment