473,382 Members | 1,710 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,382 software developers and data experts.

How to get row count in dataGrid C#

J
Does anyone know how to get the row count for a datagrid? It seems
like it should be simple, alas it is not.

datagrid1.GetRowCount?
Nov 16 '05 #1
4 39551
A DataGrid is a display widget, not a container for records. What would
RowCount be anyway -- displayed rows, or total rows?

I think you will have to examine this at the level of the underlying data
table or binding manager or whatever.

--Bob

"J" <jt*****@eudoramail.com> wrote in message
news:e2**************************@posting.google.c om...
Does anyone know how to get the row count for a datagrid? It seems
like it should be simple, alas it is not.

datagrid1.GetRowCount?

Nov 16 '05 #2
J... Never tried it but Items returns a collection and collection has a
count

http://msdn.microsoft.com/library/de...y/en-us/cpref/
html/frlrfsystemwebuiwebcontrolsdatagriditemcollectionc lasscounttopic.as
p

Regards,
Jeff
Does anyone know how to get the row count for a datagrid? It seems

like it should be simple, alas it is not.<
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #3
J wrote:
Does anyone know how to get the row count for a datagrid? It seems
like it should be simple, alas it is not.

datagrid1.GetRowCount?


You use the row count of the returned records in the appropriate table
of your dataset:

int iCnt;
iCnt = this.BindingContext[datasetname, "tablename"].Count;

--
Take care,
Ken
(to reply directly, remove the cool car. <sigh>)
Nov 16 '05 #4
Try this

int rowCount = ((DataTable)this.dataGrid1.DataSource).Rows.Count;

--
Shak
(Houston)
"J" <jt*****@eudoramail.com> wrote in message
news:e2**************************@posting.google.c om...
Does anyone know how to get the row count for a datagrid? It seems
like it should be simple, alas it is not.

datagrid1.GetRowCount?

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alpha | last post by:
I have a window application. In one of the form, a datagrid has a dataview as its datasource. Initial filtering result would give the datavew 3 items. When I double click on the datagrid to edit...
3
by: John Pether (john | last post by:
I have the following code which loads a dataset into a datagrid: <code> ' Obtain Link information from Links table ' and bind to the datagrid control Dim links As New DNSite.LinksIndexDB() '...
2
by: DC Gringo | last post by:
I have a datagrid control that has paging set up and working. What I would like is a total record count (not just per page) in the header or near the header of the datagrid. Here's my code: ...
2
by: Praveen Balanagendra via .NET 247 | last post by:
here is the source code private void AddRow() { TableCell tc = new TableCell(); tc.Controls.Add(new LiteralControl("NewRow")); DataGridItem di = new...
6
by: Tejpal Garhwal | last post by:
I have datagrid filled with some data rows. At the run time i want know how many total rows are there in the data grid ? Any idea ? Any Suggestions ? Thanks in advance Tej
1
by: Fred Morrison | last post by:
Is it just me or is there something grossly wrong with the Windows Forms DataGrid control that won't tell me the row count inside it? I'm not talking about just visible rows (what the heck good is...
8
by: Doug Bell | last post by:
Hi, I need to create a function that will return the number of columns in a passed reference to a DataView. I can find the number of columns in its underlying Data table but have not been...
2
by: james | last post by:
I have been looking for a way to reproduce the tooltip that Access displays when scrolling the Datagrid that shows the record count (changes as you move the thumb up or down). So far, nothing I...
2
by: patang | last post by:
I found the following to count the total number of VISIBLE rows of datagrid datagrid.visiblerowcount How do we count the total number of ACTUAL (not just visible) rows of datagrid? Thanks...
4
by: Peter W Johnson | last post by:
Hi guys, I have a problem with a datagrid record count. Here is the code:- <snip> Public Class frmMerchantDeposit Inherits System.Windows.Forms.Form Dim myconnection As New...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.