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