Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - databound datagrid to sql with rollup

 
Thread Tools Search this Thread
Old 01-19-2006, 05:34 PM   #1
Default databound datagrid to sql with rollup


I have a SQL Server 2003 stored procedure that uses "select ... group
by ... with rollup" syntax. The total of columns from the query varies
from 3 to 4. The query returns several rollup generated null column
rows. In an ASP.Net form, I have a datagrid.DataSource bound to the
query result from a DataReader. The grid has AutoGenerateColumns =
false. I manually add 1st and 2nd columns of the datagrid. The query
result is bound to columns starting at 3rd column. How do I program
the grid so that only the rows with all null (grand total) or one null
are displayed in the grid? I have the following code in the grid's
ItemDataBound event. Is there an easier way to do this? Filter the
result in SQL database query or use the Filter property in the
datagrid? Thanks.

private void MyDataGrid_ItemDataBound(object sender,
DataGridItemEventArgs e)
{
try
{
byte byteSummaryColumnCount = 0;
if (e.Item.ItemType == ListItemType.AlternatingItem ||
e.Item.ItemType == ListItemType.Item)
{
for (byte byteGridCell =2; byteGridCell < e.Item.Cells.Count-1;
byteGridCell++)
{
if (e.Item.Cells[byteGridCell].Text == "All")
byteSummaryColumnCount++;
}
}
switch(e.Item.ItemType)
{
case ListItemType.AlternatingItem:
if (byteSummaryColumnCount != e.Item.Cells.Count - 3 &&
byteSummaryColumnCount != e.Item.Cells.Count - 4)
e.Item.Visible = false;
break;
case ListItemType.Item:
if (byteSummaryColumnCount != e.Item.Cells.Count - 3 &&
byteSummaryColumnCount != e.Item.Cells.Count - 4)
e.Item.Visible = false;
break;
}//end of switch
}
catch(Exception ex)
{
showMessage(ex);
}
}



js
  Reply With Quote
Old 01-19-2006, 08:14 PM   #2
js
 
Posts: n/a
Default Re: databound datagrid to sql with rollup
Thanks for your interest. I got the problem solved by adding a
"HAVING" clause in the SQL statement.



js
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading 24,000 rows into C# .net Datagrid Kagu Software 0 03-10-2009 06:51 PM
Prerequisites 70-745 (Business Intelligence) Valmont MCITP 3 06-24-2008 03:03 PM
SQL Server 2008 delayed into Q3 2008 darrilgibson@cox.net MCITP 0 01-27-2008 10:26 PM
MCITP SQL Server 2005 or SQL Server 2008 Darrilgibson@gmail.com MCITP 0 12-19-2007 01:56 PM
SQL Server 2005 Migration Assistant Autonumber problem. LarryWestMCSD MCTS 1 03-28-2007 02:08 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

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