I have a gridview in which dtasource binded is a List which returns class type. If no records in list, I want to display 'No records found' in GridView.
List<Ticket> ticketList = new List<Ticket>();
ticketList = _tktBusiness.ReadAll(_tkt);
if (ticketList.Count > 0)
{
gridTicketList.DataSource = ticketList;
gridTicketList.DataBind();
}
else
{
}
In else part, what code i have to write to get desired output?Can anybody help?
You could use EmptyDataTemplate
property of your grid. It gets or sets the user-defined content for the empty data row rendered when a GridView control is bound to a data source that does not contain any records. E.g.
<asp:gridview ...
<emptydatatemplate>
No Data Found.
</emptydatatemplate>
</asp:gridview>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With