473,396 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Hide datagrid when it contains no rows

i want to know is there a way to check wherether is there data inside a datagrid and hide the datagrid when there isn't any.
for example i drag the datagridview from the toolbox and put it on the windows form, then in the coding i put :
"select * from table where balance <50";
it should display only items below 50, but when there isn't any(all items are above 50), i want to hide the datagrid....is there a way to do this?
Nov 21 '07 #1
4 1509
dip_developer
648 Expert 512MB
i want to know is there a way to check wherether is there data inside a datagrid and hide the datagrid when there isn't any.
for example i drag the datagridview from the toolbox and put it on the windows form, then in the coding i put :
"select * from table where balance <50";
it should display only items below 50, but when there isn't any(all items are above 50), i want to hide the datagrid....is there a way to do this?
what is the problem..? Datagrid has a visible property...make it to False when needed.....

when number of records ==0 make Datagrid.Visible=False......after that make it to true when needed......
Nov 21 '07 #2
thats what i thought so also...but is there a way like to know if it is zero?
how you translate "number of records=0" into C#?
Nov 21 '07 #3
dip_developer
648 Expert 512MB
thats what i thought so also...but is there a way like to know if it is zero?
how you translate "number of records=0" into C#?
are you using datset or datareader..??? then they have a Count property .......you can have the total number of records by writing
myDataSet.Tables(0).Rows.Count or myDataReader.RecordsAffected
Expand|Select|Wrap|Line Numbers
  1.  if (myDataSet.Tables(0).Rows.Count = 0) 
  2. {
  3. DataGrid1.Visible=False
  4. }
  5. else
  6. {
  7. DataGrid1.Visible=True
  8. }
  9.  
Nov 21 '07 #4
are you using datset or datareader..??? then they have a Count property .......you can have the total number of records by writing
myDataSet.Tables(0).Rows.Count or myDataReader.RecordsAffected
Expand|Select|Wrap|Line Numbers
  1.  if (myDataSet.Tables(0).Rows.Count = 0) 
  2. {
  3. DataGrid1.Visible=False
  4. }
  5. else
  6. {
  7. DataGrid1.Visible=True
  8. }
  9.  
this is it....thank you very much!!!
Nov 21 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell...
3
by: Newbie | last post by:
I am using a Datagrid to show the contents of a DataTable. But it seems like the Datagrid is not getting the contents of the Datatable when the button ( btnAddAnotherLaborCategory) is clicked. ...
2
by: Dominic | last post by:
Hi guys, I'm not sure if this question belongs to FAQ, but I couldn't find a concrete answer. I created a Datagrid control using ItemTemplate, but it's NOT a in-place editing datagrid. One of...
1
by: Machi | last post by:
Let say i select rows of records with 4 columns from Database and want to display the data in DataGrid (ASP.NEt Server Control) with one column which must be displayed in CheckBox layout. For the...
2
by: Bob Hollness | last post by:
Hi group. I am a newbie to ASP.NET as you will see from some of the questions I may ask! I have a datagrid which I have populated from a database. It works great! I have added a column, via...
1
by: jimb | last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I can't read it. Anybody have a working example of a dropdownlist in an editable grid? Thanks. -- .....
11
by: jimstruckster | last post by:
I have a table with 10 rows, I want all rows except for the first to be hidden when the page first opens up. If the user puts a value in a text box in the first row then I want the second row to...
1
by: sp | last post by:
Hello I have a problem with the refresh performance in datagrid – when datagrid is being shown it is so slow that I can see one by one cells is drawn -datagrid contains about 35x40 of...
10
by: amiga500 | last post by:
Hello, I have one basic simple question. When I have multiple records in the datagrid as follows: Code Product 1 Product 2 Product 3 11111 A B C...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.