Click here to Skip to main content
16,010,673 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Solution:
In Gridview_Paint event

C#
private void gvwPrinterLocation_Paint(object sender, PaintEventArgs e)
       {
           try
           {
               DataGridView sndr = (DataGridView)sender;
               if (sndr.Rows.Count == 0) // <-- if there are no rows in the DataGridView when it paints, then it will create your message
               {
                   using (Graphics grfx = e.Graphics)
                   {
                       grfx.DrawString("No data found!", new Font("Arial", 12), Brushes.Black, new PointF(25, 25));
                   }
               }
           }
           catch (Exception ex)
           {}}
Posted
Comments
Thanks7872 17-Feb-15 5:49am    
See this : https://www.google.co.in/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=datagridview%20no%20records%20message

1 solution

Please add following code in your gridview.

XML
<asp:GridView ID="gdvId" runat="server">
       <Columns>
       </Columns>
       <EmptyDataTemplate>
           No resources found.
       </EmptyDataTemplate>
   </asp:GridView>
 
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