467,907 Members | 1,444 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,907 developers. It's quick & easy.

databound datagrid to sql with rollup

js
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);
}
}

Jan 19 '06 #1
  • viewed: 1397
Share:
1 Reply
js
Thanks for your interest. I got the problem solved by adding a
"HAVING" clause in the SQL statement.

Jan 19 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by UNIXNewBie | last post: by
1 post views Thread by Patrick Demets | last post: by
1 post views Thread by Ashwani | last post: by
1 post views Thread by GaryDean | last post: by
reply views Thread by Ike | last post: by
1 post views Thread by jfarias | last post: by
6 posts views Thread by =?Utf-8?B?QmVuLg==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.