![]() |
|
|
|||||||
![]() |
ASP Net - databound datagrid to sql with rollup |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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 |
|
|
|
|
#2 |
|
Posts: n/a
|
Thanks for your interest. I got the problem solved by adding a
"HAVING" clause in the SQL statement. js |
|
![]() |
| Thread Tools | Search this Thread |
|
|
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 |