Click here to Skip to main content
15,886,611 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I have the gridview.

How to display "No Records found" in the grid if record is not there in the gridview instead of displaying gridview code..
Posted

 
Share this answer
 
<EmptyDataTemplate>

Oops..! No Records Found </EmptyDataTemplate>
Hope this will help you.
 
Share this answer
 
v5
Hi,


You can try like this...


C#
for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
            {
                for (int j = 0; j < dataGridView1.Columns.Count - 1; j++)
                {
                    if (this.dataGridView1.Rows[i].Cells[j].Value.ToString() == "")
                    {
                        this.dataGridView1.Rows[i].Cells[j].Value = "No Records Found";
                    }
                }
}


Thanks..
 
Share this answer
 
under that grideview take a label make it visible false.
use this code

C#
if(dataGridView1.Rows.Count>0)
{
// your display code
}
else
{
label1.Text="No records found";
Lable1.Visible=true;
}
 
Share this answer
 
v2
In grid view , u have to add this in .aspx page

HTML
<emptydatatemplate>
      No record found
</emptydatatemplate>
 
Share this answer
 
Comments
TrushnaK 22-Jul-14 3:59am    
you are too late to give answer... Question is asked on 4-Aug-11 23:38pm

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