Click here to Skip to main content
11,712,241 members (65,553 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.0 Forms
Hi Friends,
I have a problem in datagridview control while working with desktop application.
I use data set to bind this datagridview.If dataset is not empty it display all records in datagridview.
Suppose Data set is empty,I want give message to the user "No Record founds" and display it in the single row of datagridview.

Please Help me.

Thanks in Advance..



Randeep Chauhan...
Posted 23-May-11 0:38am
Edited 23-May-11 1:02am
Prerak Patel141.2K
v4
Comments
CS2011 at 23-May-11 7:14am
   
See my soluation. Hope it helps.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
Dalek Dave at 23-May-11 6:53am
   
Nice Link.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Try following.Basically dataset.fill returns number of rows returned by your query

int rows = DatasetName.fill(dataadapter,"tablename");
if(rows <= 0)
{
  //Add a row to data grid and display your msg
}
else
{
  //do what needs to be done
}
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

<EmptyDataTemplate>
                                                <table width="100%">
                                                    <tr>
                                                        <td class="ob_gNRM" style="height: 40px; text-align: center">
                                                            There are no records available.
                                                        </td>
                                                    </tr>
                                                </table>
                                            </EmptyDataTemplate>
  Permalink  
Comments
skantg at 23-May-11 7:30am
   
This one is perfect without any server side coding.
emptyDataTemplate take care of blank grid by itself.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi...

You can put inside the grid view control

and give you message inside this tag like

No Record founds


This will help you...

Try it..
  Permalink  
v2
Comments
Member 7688919 at 23-May-11 6:50am
   
But i am working in window application not web application


Thanks for reply
Randeep Chauhan
Deepthi Aravind at 23-May-11 7:12am
   
sorry..its my mistake..
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

<asp:gridview id="GridView1" datakeynames="Id" emptydatatext="No Records" showheader="true" runat="server" autogeneratecolumns="False" allowpaging="True" xmlns:asp="#unknown">
 
/* Bind Your GridView  with DataSet and set [EmptyDataText]="No Record"  </asp:gridview>
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

I had st1 as the datgrid...



If st1.RecordCount = -1 Then
GoTo TrySt1Rd1
Else
GoTo GotSt
End If



The object returned a -1 if there were no records
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 CHill60 335
1 Sergey Alexandrovich Kryukov 254
2 OriginalGriff 230
3 Andy Lanng 160
4 Maciej Los 130
0 CHill60 335
1 Sergey Alexandrovich Kryukov 245
2 OriginalGriff 230
3 Andy Lanng 160
4 Maciej Los 130


Advertise | Privacy | Mobile
Web02 | 2.8.150819.1 | Last Updated 23 May 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100