473,412 Members | 2,994 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

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
1 1535
js
Thanks for your interest. I got the problem solved by adding a
"HAVING" clause in the SQL statement.

Jan 19 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: UNIXNewBie | last post by:
Am looking at an Oracle SQL reference book. They have the following SQL for ROLLUP which works SELECT 0.YEAR, TO_CHAR(TO_DATE(O.MONTH, 'MM'), 'Month') MONTH, R.NAME REGION, SUM(O.TOT_SALES)...
1
by: Patrick Demets | last post by:
I have a fairly simple form with databound text boxes, but changes (or new records) are not recognized. The text boxes are successfully populated with data (from the database) and I can cycle...
2
by: Gummy | last post by:
Hello All, I have a webpage that has two dropdown listboxes. Based on what is selected in these dropdown listboxes, it filters a DataGrid . That works fine. In the DataGrid , when I go to edit...
1
by: Ashwani | last post by:
Hi, I am getting below error while using the ItemTemplate in datagrid. Please help, this is very very urgent. CS0117: 'System.Web.UI.DataBinder' does not contain a definition for 'eval' ...
1
by: GaryDean | last post by:
It seems every time I try to use the GridView to do what I used to do with the DataGrid I run into differences that make me want to got back to the datagrid. for instance... the DataGrid...
0
by: Ike | last post by:
When I use "With rollup," I am getting totals on columns which are numeric, however, non-numeric columns are copying down to the rollup column (i.e. the last column's non-numeric columns are being...
1
by: jfarias | last post by:
Hello all, The problem I am having is in one of the datagrids I added a new column. When I run the application data is not shown in the new column. I am using VS.NET 2003 and am connecting to a...
6
by: =?Utf-8?B?QmVuLg==?= | last post by:
Hi, I'm more of a windows programmer than ASP and I've having a little difficulty in ASP.Net (framework 2.0) - VB.net I have a datagrid on an aspx page and the html is building the display in...
2
by: ree321 | last post by:
I tried moving an ASP.net project form 1.1 to 2.0. But I am having problems with getting the OnItemDataBound function to run for a datagrid, in 2.0. It only gets called up if AutoGenerateColumns...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.