Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Show DataGrid Item Count?

Reply
Thread Tools

Show DataGrid Item Count?

 
 
Allen Davis
Guest
Posts: n/a
 
      04-30-2004
I have a DataGrid in an ASP.NET page that is the third of three nested controls (2 DataLists and the DataGrid). It uses relations in the DataSet and a DataView RowFilter to determine what data to bind to and display. What I'd like to do is show a count of items in the DataGrid header but I can't find a method for this. Does anyone have any suggestions?
 
Reply With Quote
 
 
 
 
Saravana [MVP]
Guest
Posts: n/a
 
      05-05-2004
You can calculate the count using datagrid.items. But datagrid items will
include header,footer and pager. If you have any of these items, then
substract these from datagrid.items. Then it will give you total number of
items in that datagrid. I hope this should help you

--
Saravana
Microsoft MVP - ASP.NET
www.extremeexperts.com



"Allen Davis" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have a DataGrid in an ASP.NET page that is the third of three nested

controls (2 DataLists and the DataGrid). It uses relations in the DataSet
and a DataView RowFilter to determine what data to bind to and display. What
I'd like to do is show a count of items in the DataGrid header but I can't
find a method for this. Does anyone have any suggestions?


 
Reply With Quote
 
 
 
 
Carlos CR
Guest
Posts: n/a
 
      05-05-2004
"Saravana [MVP]" <(E-Mail Removed)> wrote in
news:uG#(E-Mail Removed):

> You can calculate the count using datagrid.items. But datagrid items
> will include header,footer and pager. If you have any of these items,
> then substract these from datagrid.items. Then it will give you total
> number of items in that datagrid. I hope this should help you


Or if you are using a DataView to fetch de DataGrid you can use
DataView.Count.

Hope it helps

Carlos CR
 
Reply With Quote
 
Allen Davis
Guest
Posts: n/a
 
      05-05-2004
Thanks, Saravana, Carlso. And, as Carlos suggested in his reply, I do have a function that uses the DataView to get the count as shown here

Function PassengerCount(ByVal DataItem As Object) As Integer
Dim drv As DataRowView = DataItem
Dim intPassengers As Integer
intPassengers = drv.DataView.Count()
PassengerCount = intPassengers
End Function

Though I'm not certain that's the most efficient way to do it. But, because I'm using BoundColumns in the ASP.NET page, I can't call this function as the value of HeaderText for one of those BoundColumns. I can use GetChildRelation from the DataList one level above the DataGrids, get a count from the resulting DataView and display the results there. But I want to show the count with each DataGrid not just once in the containing DataList. But generating a DataView twice instead of once seems wasteful.

Any thoughts about how to display the results in the header of the DataGrids?

----- Saravana [MVP] wrote: -----

You can calculate the count using datagrid.items. But datagrid items will
include header,footer and pager. If you have any of these items, then
substract these from datagrid.items. Then it will give you total number of
items in that datagrid. I hope this should help you

--
Saravana
Microsoft MVP - ASP.NET
www.extremeexperts.com



"Allen Davis" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have a DataGrid in an ASP.NET page that is the third of three nested

controls (2 DataLists and the DataGrid). It uses relations in the DataSet
and a DataView RowFilter to determine what data to bind to and display. What
I'd like to do is show a count of items in the DataGrid header but I can't
find a method for this. Does anyone have any suggestions?



 
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
How to get data from parent datagrid item from child datagrid dataitem Skowronek ASP .Net 4 12-04-2007 07:34 PM
XHTML block item inside and inline item tj.tzavaras@gmail.com HTML 2 04-28-2005 03:42 PM
How to know if a datagrid item will be displayed in a datagrid with pagging CFirmino ASP .Net Datagrid Control 1 04-04-2004 12:39 AM
Change style of a single row of the item list of datagrid, based on a field value of current item... QUASAR ASP .Net Datagrid Control 6 01-17-2004 07:46 PM
Display Related Item or Add Item ssoss ASP .Net 2 09-18-2003 11:35 PM



Advertisments