Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > total record count in datagrid

Reply
Thread Tools

total record count in datagrid

 
 
DC Gringo
Guest
Posts: n/a
 
      03-04-2004
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:

<aspataGrid
AllowCustomPaging="false"
AllowPaging="true"
AllowSorting="true"
AlternatingItemStyle-BackColor="#EFEFEF"
AutoGenerateColumns="false"
Border="0"
Cellpadding="4"
Cellspacing="0"
CssClass="DataGrid"
DataKeyField="clnGUID"
Enabled="true"
EnableViewState="true"
HeaderStyle-BackColor="Black"
HeaderStyle-Font-Bold="True"
HeaderStyle-ForeColor="White" id="DataGrid2" runat="server"
ShowFooter="false"
OnSortCommand="SortCommand_OnClick"
OnPageIndexChanged="PageIndexChanged_OnClick"
PageSize="50"
PagerStyle-Mode="NumericPages"
PagerStyle-HorizontalAlign="Right"
ShowHeader="true"
>




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

Sub Page_Load(Source 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.DataSource = myDataSet1.Tables("CommunitiesT1")


DataGrid2.DataBind()


End Sub
--
_____
DC G


 
Reply With Quote
 
 
 
 
Morgan
Guest
Posts: n/a
 
      03-04-2004
You could use the Rows.Count property off of your dataset table.
myDataSet1.Tables("CommunitiesT1").Rows.Count

HTH,

Morgan
"DC Gringo" <> wrote in message
news:%...
> 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:
>
> <aspataGrid
> AllowCustomPaging="false"
> AllowPaging="true"
> AllowSorting="true"
> AlternatingItemStyle-BackColor="#EFEFEF"
> AutoGenerateColumns="false"
> Border="0"
> Cellpadding="4"
> Cellspacing="0"
> CssClass="DataGrid"
> DataKeyField="clnGUID"
> Enabled="true"
> EnableViewState="true"
> HeaderStyle-BackColor="Black"
> HeaderStyle-Font-Bold="True"
> HeaderStyle-ForeColor="White" id="DataGrid2" runat="server"
> ShowFooter="false"
> OnSortCommand="SortCommand_OnClick"
> OnPageIndexChanged="PageIndexChanged_OnClick"
> PageSize="50"
> PagerStyle-Mode="NumericPages"
> PagerStyle-HorizontalAlign="Right"
> ShowHeader="true"
> >

>
>
>
> Protected _sqlStmt As String = _
> "SELECT cols FROM tables"
>
> Sub Page_Load(Source 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.DataSource = myDataSet1.Tables("CommunitiesT1")
>
>
> DataGrid2.DataBind()
>
>
> End Sub
> --
> _____
> DC G
>
>



 
Reply With Quote
 
 
 
 
nfedin
Guest
Posts: n/a
 
      03-04-2004
Why not check your DataTable to see how many rows it has?

i.e. RecordCount = myDataSet1.Tables("CommunitiesT1").Rows.Count

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

Neil

"DC Gringo" <> wrote in message news:<#>...
> 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:
>
> <aspataGrid
> AllowCustomPaging="false"
> AllowPaging="true"
> AllowSorting="true"
> AlternatingItemStyle-BackColor="#EFEFEF"
> AutoGenerateColumns="false"
> Border="0"
> Cellpadding="4"
> Cellspacing="0"
> CssClass="DataGrid"
> DataKeyField="clnGUID"
> Enabled="true"
> EnableViewState="true"
> HeaderStyle-BackColor="Black"
> HeaderStyle-Font-Bold="True"
> HeaderStyle-ForeColor="White" id="DataGrid2" runat="server"
> ShowFooter="false"
> OnSortCommand="SortCommand_OnClick"
> OnPageIndexChanged="PageIndexChanged_OnClick"
> PageSize="50"
> PagerStyle-Mode="NumericPages"
> PagerStyle-HorizontalAlign="Right"
> ShowHeader="true"
> >

>
>
>
> Protected _sqlStmt As String = _
> "SELECT cols FROM tables"
>
> Sub Page_Load(Source 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.DataSource = myDataSet1.Tables("CommunitiesT1")
>
>
> DataGrid2.DataBind()
>
>
> End Sub

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BT Total Broadband vs BT Business Total John Y UK VOIP 2 02-02-2007 09:27 AM
I am adding a new row to the datagrid dynamically but if i use the Count property of Item it is not showing the count of the new rows being added Praveen Balanagendra via .NET 247 ASP .Net 2 06-06-2004 07:16 AM
total record count in datagrid DC Gringo ASP .Net Datagrid Control 0 03-04-2004 03:36 PM
Pix 501 SNMP total Byte Count stedlar Cisco 3 02-18-2004 02:48 AM
Getting Total Item Count in Paging Datagrid jason smith ASP .Net Datagrid Control 4 07-23-2003 05:34 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57