473,785 Members | 2,363 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

total record count in datagrid

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:

<asp:DataGrid
AllowCustomPagi ng="false"
AllowPaging="tr ue"
AllowSorting="t rue"
AlternatingItem Style-BackColor="#EFE FEF"
AutoGenerateCol umns="false"
Border="0"
Cellpadding="4"
Cellspacing="0"
CssClass="DataG rid"
DataKeyField="c lnGUID"
Enabled="true"
EnableViewState ="true"
HeaderStyle-BackColor="Blac k"
HeaderStyle-Font-Bold="True"
HeaderStyle-ForeColor="Whit e" id="DataGrid2" runat="server"
ShowFooter="fal se"
OnSortCommand=" SortCommand_OnC lick"
OnPageIndexChan ged="PageIndexC hanged_OnClick"
PageSize="50"
PagerStyle-Mode="NumericPa ges"
PagerStyle-HorizontalAlign ="Right"
ShowHeader="tru e"


Protected _sqlStmt As String = _
"SELECT cols FROM tables"

Sub Page_Load(Sourc e As Object, E As EventArgs)
If Not Page.IsPostBack Then
BindData()
End If
End Sub

Sub BindData()
Dim conString As String = "server=server; database=db;uid =user;pwd=pwd;"

Dim myDataSet1 As New DataSet
Dim myDataAdapter1 As New SqlDataAdapter( _sqlStmt, conString)
myDataAdapter1. Fill(myDataSet1 , "CommunitiesT1" )
DataGrid2.DataS ource = myDataSet1.Tabl es("Communities T1")
DataGrid2.DataB ind()
End Sub
--
_____
DC G
Nov 18 '05 #1
2 6966
You could use the Rows.Count property off of your dataset table.
myDataSet1.Tabl es("Communities T1").Rows.Cou nt

HTH,

Morgan
"DC Gringo" <dc******@visio ntechnology.net > wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
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:

<asp:DataGrid
AllowCustomPagi ng="false"
AllowPaging="tr ue"
AllowSorting="t rue"
AlternatingItem Style-BackColor="#EFE FEF"
AutoGenerateCol umns="false"
Border="0"
Cellpadding="4"
Cellspacing="0"
CssClass="DataG rid"
DataKeyField="c lnGUID"
Enabled="true"
EnableViewState ="true"
HeaderStyle-BackColor="Blac k"
HeaderStyle-Font-Bold="True"
HeaderStyle-ForeColor="Whit e" id="DataGrid2" runat="server"
ShowFooter="fal se"
OnSortCommand=" SortCommand_OnC lick"
OnPageIndexChan ged="PageIndexC hanged_OnClick"
PageSize="50"
PagerStyle-Mode="NumericPa ges"
PagerStyle-HorizontalAlign ="Right"
ShowHeader="tru e"
>


Protected _sqlStmt As String = _
"SELECT cols FROM tables"

Sub Page_Load(Sourc e As Object, E As EventArgs)
If Not Page.IsPostBack Then
BindData()
End If
End Sub

Sub BindData()
Dim conString As String = "server=server; database=db;uid =user;pwd=pwd;"

Dim myDataSet1 As New DataSet
Dim myDataAdapter1 As New SqlDataAdapter( _sqlStmt, conString)
myDataAdapter1. Fill(myDataSet1 , "CommunitiesT1" )
DataGrid2.DataS ource = myDataSet1.Tabl es("Communities T1")
DataGrid2.DataB ind()
End Sub
--
_____
DC G

Nov 18 '05 #2
Why not check your DataTable to see how many rows it has?

i.e. RecordCount = myDataSet1.Tabl es("Communities T1").Rows.Cou nt

This will give all the records being bound to the data grid.

Neil

"DC Gringo" <dc******@visio ntechnology.net > wrote in message news:<#E******* *******@TK2MSFT NGP10.phx.gbl>. ..
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:

<asp:DataGrid
AllowCustomPagi ng="false"
AllowPaging="tr ue"
AllowSorting="t rue"
AlternatingItem Style-BackColor="#EFE FEF"
AutoGenerateCol umns="false"
Border="0"
Cellpadding="4"
Cellspacing="0"
CssClass="DataG rid"
DataKeyField="c lnGUID"
Enabled="true"
EnableViewState ="true"
HeaderStyle-BackColor="Blac k"
HeaderStyle-Font-Bold="True"
HeaderStyle-ForeColor="Whit e" id="DataGrid2" runat="server"
ShowFooter="fal se"
OnSortCommand=" SortCommand_OnC lick"
OnPageIndexChan ged="PageIndexC hanged_OnClick"
PageSize="50"
PagerStyle-Mode="NumericPa ges"
PagerStyle-HorizontalAlign ="Right"
ShowHeader="tru e"
>


Protected _sqlStmt As String = _
"SELECT cols FROM tables"

Sub Page_Load(Sourc e As Object, E As EventArgs)
If Not Page.IsPostBack Then
BindData()
End If
End Sub

Sub BindData()
Dim conString As String = "server=server; database=db;uid =user;pwd=pwd;"

Dim myDataSet1 As New DataSet
Dim myDataAdapter1 As New SqlDataAdapter( _sqlStmt, conString)
myDataAdapter1. Fill(myDataSet1 , "CommunitiesT1" )
DataGrid2.DataS ource = myDataSet1.Tabl es("Communities T1")
DataGrid2.DataB ind()
End Sub

Nov 18 '05 #3

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

Similar topics

0
1373
by: Richard Holliingsworth | last post by:
Hello: I'm building a report to display statistics on the entire database. I have successfully built a report that groups the entire db on one field and gives me a count of db records for the categories in that field and a total record count for the db. Now, I need to add another "total database" grouping to get another set of record counts. I DO NOT want to nest this group, It MUST consider ALL database records.
2
35896
by: mhodkin | last post by:
I created a query in which I have grouped data by City. I wish to calculate the percent of each value, e.g. City/(Total count of all Cities), in tbe next column of the query. I can't seem to write the correct expression due to the "groupby" needed to group the city count in the first column. Any clues?
0
3645
by: Patrick | last post by:
I'm working on a contact management application, and need a hand with one aspect... Here's what I want to create: ------------------------------------ A form split into two parts. There is a datagrid on the left side that lists names and perhaps a couple of other key fields. The user can click on a record in the datagrid, which should automatically pull up details on that record in the various text boxes and other controls on the right...
0
2138
by: buran | last post by:
Dear ASP.NET Users, How can I get the total number of rows selected by the command text of the datagrid (items in datagrid)? If I use the statement grdSP.Items.Count with the datagrid grdSP with paging, it returns the page size (5,10..) not the total results. How can I get the total no? Thanks in advance, Buran
0
1585
by: Terry Olsen | last post by:
Is there a way to get the total column count in a DataGrid? I can get the total _visible_ columns, but I need to know how many _total_ columns are in my grid. Thanks!
2
11125
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 in advance.
4
3091
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 Odbc.OdbcConnection("DSN=database")
19
3116
by: hotflash | last post by:
Hi CroCrew et. All, I am currently working on a quick report that count a total of completed records per Individual. The code that I have will add up all Individual completed records and what I want is to get a total for each of the Individuals per month. For example, CroCrew .... .... Total = 2 Jim
0
1734
by: sumitdipsite2005 | last post by:
I am trying to use VB6 as a middleware between two 3rd party applications. "App. A" ----> VB6 ------> "App B" i am having no trouble sending data from VB to the "App B". But i am having some trouble in reading data from "App A".
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9485
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10356
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10161
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10098
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9958
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8986
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
4058
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3662
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.