How to add default text as 'No record found' in Gridview,when there is no data?

 Posted by vishalneeraj-24503 on 12/5/2013 | Category: ASP.NET Interview questions | Views: 2583 | Points: 40
Answer:

We can add text as 'No record found' in Gridview,when there is no data with the help of EmptyDataText property.

For ex:-
<asp:GridView ID="grid_view_employee_details" runat="server" AllowPaging="true" AutoGenerateColumns="false"


EmptyDataText = "No record(s) found"
OnRowDataBound="grid_view_employee_details_RowDataBound" OnSelectedIndexChanged ="grid_view_employee_details_SelectedIndexChanged">
</asp:GridView>


When gridview binds with dataset object or any other object,and that object is null or empty,then "No record(s) found" text will be displayed in GridView.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response