How do you get the number of rows

I have a gridview and I want to display the total number of rows of data like 5000 rows?

This is not the same as the GridView1.Rows.Count, which gives the number of rows being displayed like 10 of 5000 rows.

How do I get at the total?

0
craigbtx
1/8/2006 8:12:17 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

9 Replies
1103 Views

Similar Articles

[PageSpeed] 32

Hi,

i think what you are asking is how to get the number of rows of the bounded dataset. Lets say you bound a dataset to the grid, you only need to get the number of rows of the first table in the dataset:

myDataset.tables(0).rows.count

As simple as that!

 

regards,

njs

0
NJS
1/8/2006 8:36:21 PM

That works in ASP.NET 1.x

That doesn't work in ASP.NET 2.0s gridview unless I am missing something

0
craigbtx
1/8/2006 11:08:09 PM
You need to count the rows from the DataSource! 

HighOnCoding
Wanna get high!
0
azamsharp
1/9/2006 4:23:59 AM

You mean loop through the records incrementing a counter?

That means passing throught the results twice. Once to display the in a gridview and once to count the rows. Never had to do this in past versions. I don't think Microsoft would make you do this.

Isn't there a better way???

0
craigbtx
1/9/2006 12:55:03 PM

Hi,

I was playing with the SqlDataSource control last weekend and saw it can be done in the Selected event. This is completely out of my head but please try this:

e.AffectedRows    where e is of type SqlDataSourceStatusEventArgs

Grz, Kris.


Read my blog. Handy Firefox plugins for web developers.


Workaround for non working Mark as answer buttons.
0
XIII
1/9/2006 1:08:31 PM
If your data is comming from Database and I assume it is then you can write a simple query that returns the total number of records in the table. 

Something like this:

SELECT COUNT(*) FROM MyTable

In the above query is will also return NULL rows if you don't want NULL rows then you can do something like this:

SELECT COUNT(MyTableID) FROM MyTable
where MyTableID is the primary key of the MyTable.

Hope it helps!

HighOnCoding
Wanna get high!
0
azamsharp
1/9/2006 2:11:20 PM
There is a count feature in a gridview.
0
SinkableHail
1/9/2006 2:13:20 PM

Awesome that is it!!!!

In the SqlDataSource1_Selected event use
e.AffectedRows to get the total number of rows in the datasource.

Looping through the rows and incrementing a counter or doing 2 selects against the database is not the best way. Imagine if you had millions of records, as I have!!!!! Plus in ASP.NET 1.1 all you had to do was Dataset.tblMyTable.count

0
craigbtx
1/9/2006 3:30:04 PM

craigbtx wrote:
Looping through the rows and incrementing a counter or doing 2 selects against the database is not the best way.

That's my thought also. There's no need to hit a database again when you have it already at your disposal.

Grz, Kris.


Read my blog. Handy Firefox plugins for web developers.


Workaround for non working Mark as answer buttons.
0
XIII
1/9/2006 7:09:42 PM
Reply:

Similar Artilces:

How to set the row number and get the row number for ("selected row) in Datagrid
I face a problem that i can't get the selected row of the datagrid in both server side script (VB.net) and client side script (javascript) As i can't use the button column / hyperlink column in the datagrid. Thus , i need to handle the change the background color of the selected row and also to get the selected row number for Update/Delete. Thanks in advance. This depends on how do you perform the selection. Do you want to implement chaning of the SelectedRow at the client side without any postback? If you have no issues with postback, then you can do s little trick here: 1. ...

Get the Row Number or Row ID
Hi, I am using Sybase Central v4.3 with Interactive SQL to query the SQL Commands. My concern is how to get the rownumber or row id in select queries. Is there any in built commands in the ASE. If not please suggest me how to get the rownumber. Thanks.... Unless i'm mistaken, ASE does not use a rowid... it can have a timestamp, but it is updated with every modification to the row. http://infocenter.sybase.com/help/topic/com.sybase.help.ase_15.0.blocks/html/blocks/blocks34.htm -- Cory Sane [TeamSybase] Certified Sybase Associate DBA for ASE 15.0 "Santhanam P" wrote...

How to get the row index of a selected row in listview control
Can someone please tell me how to get the index of a selected row in a listview.  <ItemTemplate> <asp:LinkButton runat="server" class="linkButton" id="xxxxx" Text='<%#Eval("documenttype") %>' CommandName="OpenFile" CommandArgument='<%#Eval("DocumentKey") %>'></asp:LinkButton></ItemTemplate>what you have to do is, in itemcommand event of ListView, you have to get the value of row indexif(e.CommandName == "corrospondingcommaandname"){     &nb...

Getting Information from the Controls (TemplateField or BoundField ) from any of the Data Presentation Controls
Hello Everybody,I have a very important question for me.For example, I have a GridView.It has three BoundFields and one TemplateFieldI want to get information from any of the record (row,line etc ) using any of the BoundFields or TemplateFields.And also I want to accomplish this not only with GridView but also other Data Presentation Controls, DetailsView FormView and Repeater.Shortly, Can anybody help me how to refer Controls in GridView, FormView, DetailsView, RepeaterPS: I have searched in Google and many sites,forums. But I couldn't see any solution and see that many people ask the same ...

The row number and offset of each row in the page should have a matching entry in row number table
Is the proper correction for the following to recreate the table BCPout/IN or table to table insert, or just drop and recreate the index? Row number is 0. Is there a way to correct just the data page? Table Corrupt: The row number and offset of each row in the page should have a matching entry in row number table; check this page (page#=772121 row#=0 offset in row number table=0) Table Corrupt: The row number and offset of each row in the page should have a matching entry in row number table; check this page (page#=772121 row#=0 offset in row number table=0) Table Corrupt: The row...

getting the number of rows...
how can you get the number of rows in query resault with out filling dataset and checking the "count"? afaik - you can't - - you've got to have an entity to count the rows - the dataset is the 'finished product' that contains the result of your query - until you've queried and received the data from the database, you don't know how many rows you've receivedDavid WierMCP/ASPInsiderASPNet101.com - where to look first!Control Grouper - easily control properties for multiple controls with one control!Calendar Express - The Best HTML Calendar Generator on the web!(Please 'Mark as ...

How to delete row from GridView control
Hello,  I am working on an ASP.NET 2.0 app, and I am trying to wire up a "Delete" button to a gridview control on a form. Here is the code for the ASP :  <asp:GridView ID="gvInConditions" runat="server" AutoGenerateColumns="true" OnRowDeleting="gvInConditions_RowDeleting" DataKeyNames="Condition_ID" >         <Columns>                <asp:CommandField ButtonType="Button" SelectText=&...

get number from row
if i have a this string to select a row from database of acess: select TOP 1 * from odkazy how i elicit from it id column? i need know id from select row then just get the id... select top 1 id from odkazy... PS..you would need an order by clause in the select statement otherwise the TOP has no meaning.. hth***********************Dinakar NethiLife is short. Enjoy it.*********************** my problem: (for example) if i have 5 columns with numbers in select row and i want display cast of this numbers I write: one = ds.tables("Odkazy").Rows(i)("...

How do I get the row number?
I have tryed to find a way to include the row number in a querry but without result. I have a table select some rows ordered and now I will add a column called rank How do I get the rownumber in the field rank ? Thanks in advance Jan O Jan O www.olsmar.com The way I'd suggest assigning a row number to your resultset is to INSERT your resultset into a temporary table or table variable which has an IDENTITY column, something like this: -- set up a table variable to hold the resultset DECLARE @myTable (Rank int identity(1,1) primary_key, ColumnA va...

using javascript getting value from textbox when edit button is clicked and both controls are present in gridview control
Hi All using javascript I want to get value  from textbox when edit button is clicked and both controls that is texbox and button are present in gridview control .Alok Hi aloksinha83, Please see this post: http://forums.asp.net/t/1069245.aspx Thanks,Qin Dian TangMicrosoft Online Community SupportPlease remember to mark the replies as answers if they help and unmark them if they provide no help....

Add new controls to a gridview row; when editing that row using the edit row feature in the gridview control.
Hi all  I have a questions that looks hard / complex to me, and i know you can help me in this. Q {  I have row in a Gridview and i have an edit option to it. I press the edit button, to edit the values in that row and update data all the way back to the database. Now when i press the edit button, i want a drop down list to be displayed that contain values for a particular field in my grid view. (for now only plain text boxes appear.) } I hope you understand my question, all i need to do is replace the text box controls with a dropdown list when i am editing a row in ...

Data presentation control in another Data presentation control
 Hello,I want to make a menu with datalist or gridview control.Basically,the menu will be like this,Categories     Sub Categories.For example, for COMPUTING category there will be NOTEBOOKS DESKTOPS etc.There will be a image for CATEGORIES and linkbuttons with Subcategories.If I put a datalist inside a datalist and a link button inside the second datalist visually it satisfies my need.However,CommandArguments come from database to linkbutton.Andwhen one of these command buttons is cliked it must go to proper page.I dont know how to wrie an event_handler ,specifically, for...

How to get rowcount or row number
Hello, Sybase experts, I have a table, when I select it I want to display row number as well. E.g. Table T1(c1,c2) c1 c2 --- --- aaa bbb ppp qqq fff ggg .... I want to get results like this: rowno c1 c2 ----- --- --- 1 aaa bbb 2 ppp qqq 3 fff ggg .... If I use: select rowno=@rowcount,c1,c2 from T1 I will get: rowno c1 c2 ----- --- --- 0 aaa bbb 0 ppp qqq 0 fff ggg .... Which is NOT what I want, but how can I do that ? Thank you very much Albert ---== Posted via the PFCGuide Web...

Getting the number of rows in a datagrid
Hi, The datagrid on my webform gets filled with some data from my database. I want to find the number of rows that are populated on the datagrid. What is the way to simply find the number of rows that have been filled with data. I want to use that in a for loop. Thanks, Snigdha After you populate your datagrid with data, all you have to do is:DataGrid.Items.CountThat will give you a count of how many rows are in your grid.DarmarkMark as Answer, if this reply answers your post. Get the row count based on your DataSource....For example, if the DaatSource is DataTable dtTable...it would ...

Web resources about - How do you get the number of rows - asp.net.presentation-controls

Number - Wikipedia, the free encyclopedia
A number is a mathematical object used to count , label, and measure . In mathematics , the definition of number has been extended over the years ...

Number - Wikipedia, the free encyclopedia
A number is a mathematical object used to count , label, and measure . In mathematics , the definition of number has been extended over the years ...

Closing the Gap: Five numbers that should shame Australia
Indigenous Australians continue to die younger, be out of work more and have less education than other Australians, the annual Closing the Gap ...

Closing the Gap: Five numbers that should shame Australia
Indigenous Australians continue to die younger, be out of work more and have less education than other Australians, the annual Closing the Gap ...

Latest U.S. smartphone market numbers show Apple in the lead, but Samsung is catching up
According to the latest U.S. smartphone market share numbers from Parks Associates, Apple is still well in the lead compared to competing manufacturers, ...

Uh-Oh! Lawyer Has Same Number As Chipotle ‘Free Burrito’ Text Line
Sorry, but this lawyer doesn't have any free food for you.

Samsung is catching up to the iPhone, by the numbers
... of the smartphone market, but its competitors are starting to catch up. Looking at the latest United States smartphone market share numbers, ...

New job listing hints at wider number of clock face options for Apple Watch
Future versions of watchOS should incorporate more clock face options, building on the 12 already included, a new Apple job listing discovered ...

“Huge” number of Mac apps vulnerable to hijacking, and a fix is elusive
Enlarge (credit: vulnsec.com) Camtasia, uTorrent, and a large number of other Mac apps are susceptible to man-in-the-middle attacks that install ...

8 charts reveal mind-boggling numbers about the monster rocket NASA is building to shuttle astronauts ...
Earlier this month, NASA announced the first mission it will be launching aboard its monster rocket, called the Space Launch System . In 2018, ...

Resources last updated: 2/10/2016 11:19:48 PM