Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: DataGrid Script


Message #1 by "Tim Farrell" <timothy.farrell@c...> on Mon, 21 Oct 2002 19:33:15
I have a Stored Procedure that produces the following result:
Component Activity Total Records Total Hours 
1           ADM         22           168 
1           CUT          5           108 
1           INSP-CODE    1             1 
1           INSP-PUBS    1             3 
1           MAINT-S     16           109 
1           RES         13           298 
1           TEST-I       1            12 
1           Total       59           699 

My DataGrid script looks like this:
<asp:DataGrid id="myDataGrid" Runat="server" Width="80%" Font-Size="9pt" 
CellPadding="2" CellSpacing="0" Gridlines="Horizontal" HeaderStyle-Font-
Bold="True" HeaderStyle-BackColor="#0000ab" HeaderStyle-
ForeColor="#ffffff" AlternatingItemStyle-BackColor="#dcdcdc" 
AutoGenerateColumns="False" BorderColor="Black">
<Columns>
<asp:BoundColumn ItemStyle-Width="25%" DataField="component" 
HeaderText="Component" />
<asp:BoundColumn ItemStyle-Width="25%" DataField="activity" 
HeaderText="Activity" />
<asp:BoundColumn ItemStyle-Width="25%" DataField="records" 
HeaderText="Total Records" />
<asp:BoundColumn ItemStyle-Width="35%" DataField="hours" HeaderText="Total 
Hours" />
</Columns>
</asp:DataGrid>

What I want to achieve is to have the Component variable be printed only 
once on the top of each grouping and the total line be in bold.  So the 
datagrid would look like:
Component Activity Total Records Total Hours 
1           ADM         22           168 
            CUT          5           108 
            INSP-CODE    1             1 
            INSP-PUBS    1             3 
            MAINT-S     16           109 
            RES         13           298 
            TEST-I       1            12 
<b>         Total       59           699 </b>

Can anyone offer some suggestions on how to achieve this?

Thank you.

Sincerely,

Tim

Message #2 by "Tim Farrell" <timothy.farrell@c...> on Mon, 21 Oct 2002 20:29:36
One thing I forgot to mention is that if you could provide either an 
example of information as it pertains to VB-Script and not c#.  I have 
found plenty examples of C#, but none for VBScript.

Thanks again.

Tim

> I have a Stored Procedure that produces the following result:
C> omponent Activity Total Records Total Hours 
1>            ADM         22           168 
1>            CUT          5           108 
1>            INSP-CODE    1             1 
1>            INSP-PUBS    1             3 
1>            MAINT-S     16           109 
1>            RES         13           298 
1>            TEST-I       1            12 
1>            Total       59           699 

> My DataGrid script looks like this:
<> asp:DataGrid id="myDataGrid" Runat="server" Width="80%" Font-Size="9pt" 
C> ellPadding="2" CellSpacing="0" Gridlines="Horizontal" HeaderStyle-Font-
B> old="True" HeaderStyle-BackColor="#0000ab" HeaderStyle-
F> oreColor="#ffffff" AlternatingItemStyle-BackColor="#dcdcdc" 
A> utoGenerateColumns="False" BorderColor="Black">
<> Columns>
<> asp:BoundColumn ItemStyle-Width="25%" DataField="component" 
H> eaderText="Component" />
<> asp:BoundColumn ItemStyle-Width="25%" DataField="activity" 
H> eaderText="Activity" />
<> asp:BoundColumn ItemStyle-Width="25%" DataField="records" 
H> eaderText="Total Records" />
<> asp:BoundColumn ItemStyle-Width="35%" DataField="hours" 
HeaderText="Total 
H> ours" />
<> /Columns>
<> /asp:DataGrid>

> What I want to achieve is to have the Component variable be printed only 
o> nce on the top of each grouping and the total line be in bold.  So the 
d> atagrid would look like:
C> omponent Activity Total Records Total Hours 
1>            ADM         22           168 
 >            CUT          5           108 
 >            INSP-CODE    1             1 
 >            INSP-PUBS    1             3 
 >            MAINT-S     16           109 
 >            RES         13           298 
 >            TEST-I       1            12 
<> b>         Total       59           699 </b>

> Can anyone offer some suggestions on how to achieve this?

> Thank you.

> Sincerely,

> Tim

Message #3 by "Peter Lanoie" <planoie@n...> on Wed, 23 Oct 2002 08:40:29 -0400
I haven't worked with datagrids yet so this might be a useless suggestion,
but...

In the code behind, can you loop through the items in the data grid?  Then
you could do some simple tests on the values.  Starting at the first row in
the grid, compare each successive value of "Component", then clear it out if
it matches the previous.  As for the total row, presuming that you can get a
row count, and therefore be able to deal directly with the last row of the
dataset, you might be able to play with the attributes.  Again, not having
worked with the datagrid object, I'm not familiar with what's available for
property, etc.  I have seen obj.Attributes collections on numerous objects,
so you might be able to adjust those for a datagrid row.  Then perhaps you
could set a CSSClass for it.

So this is such a vague answer to a specific question.  Perhaps there's
someone with datagrid experience who could answer my questions about the
object's capabilities.  Maybe if you just drill around in the intellisense
or the class browser you may be able to find this things.

hth,
Peter

-----Original Message-----
From: Tim Farrell [mailto:timothy.farrell@c...]
Sent: Monday, October 21, 2002 19:33
To: aspx_beginners
Subject: [aspx_beginners] DataGrid Script


I have a Stored Procedure that produces the following result:
Component Activity Total Records Total Hours
1           ADM         22           168
1           CUT          5           108
1           INSP-CODE    1             1
1           INSP-PUBS    1             3
1           MAINT-S     16           109
1           RES         13           298
1           TEST-I       1            12
1           Total       59           699

My DataGrid script looks like this:
<asp:DataGrid id="myDataGrid" Runat="server" Width="80%" Font-Size="9pt"
CellPadding="2" CellSpacing="0" Gridlines="Horizontal" HeaderStyle-Font-
Bold="True" HeaderStyle-BackColor="#0000ab" HeaderStyle-
ForeColor="#ffffff" AlternatingItemStyle-BackColor="#dcdcdc"
AutoGenerateColumns="False" BorderColor="Black">
<Columns>
<asp:BoundColumn ItemStyle-Width="25%" DataField="component"
HeaderText="Component" />
<asp:BoundColumn ItemStyle-Width="25%" DataField="activity"
HeaderText="Activity" />
<asp:BoundColumn ItemStyle-Width="25%" DataField="records"
HeaderText="Total Records" />
<asp:BoundColumn ItemStyle-Width="35%" DataField="hours" HeaderText="Total
Hours" />
</Columns>
</asp:DataGrid>

What I want to achieve is to have the Component variable be printed only
once on the top of each grouping and the total line be in bold.  So the
datagrid would look like:
Component Activity Total Records Total Hours
1           ADM         22           168
            CUT          5           108
            INSP-CODE    1             1
            INSP-PUBS    1             3
            MAINT-S     16           109
            RES         13           298
            TEST-I       1            12
<b>         Total       59           699 </b>

Can anyone offer some suggestions on how to achieve this?

Thank you.

Sincerely,

Tim

---
Beginning ASP.NET Databases using VB.NET
http://www.wrox.com/ACON11.asp?ISBN=1861006195

Beginning ASP.NET Databases using C#
http://www.wrox.com/ACON11.asp?ISBN=1861007418

These books look at how we can create data-centric ASP.NET
applications. Requiring some basic knowledge of ASP.NET,
Access and SQL the authors guide you through the process
of connecting and consuming information in a variety of
ways. They are packed full of excellent illustrative code
examples, demonstrating important fundamental principles.


  Return to Index