Prev: Crystal Report Connection problem
Next: Set DataNavigateUrlField to contained custom object property
From: rajiv on 13 Apr 2010 07:16 I have searched the net but have been unable to find a solution to subtotaling in a gridview. I have a gridview that is bounded to sqldatasource where I would like to subtotal rows throughout the gridview based on column value "Type". I am using VB.NET. Regards RAJIV Hutt wrote: Subtotals in Gridview 22-Jul-08 I have searched the net but have been unable to find a solution to subtotaling in a gridview. I have a gridview that is bounded to sqldatasource where I would like to subtotal rows throughout the gridview based on column value "Type". I am using VB.NET. Thanks. -- Hutty Previous Posts In This Thread: On Tuesday, July 22, 2008 1:26 PM Hutt wrote: Subtotals in Gridview I have searched the net but have been unable to find a solution to subtotaling in a gridview. I have a gridview that is bounded to sqldatasource where I would like to subtotal rows throughout the gridview based on column value "Type". I am using VB.NET. Thanks. -- Hutty On Wednesday, July 23, 2008 9:10 AM Eliyahu Goldin wrote: The way to do this sort of things is to use a repeater or a listview with The way to do this sort of things is to use a repeater or a listview with ItemTemplate made out of two html table rows. The first <tr> will be used as a regular row. The second <tr> will contain subtotals. It will be hidden for all items (rows) but the last item for each Type. You will need to handle either ItemDataBound or PreRender event to calculate the subtotals, detect the last item for every Type and show the subtotal <tr> for the detected last items. -- Eliyahu Goldin, Software Developer Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net "Hutty" <Hutty(a)discussions.microsoft.com> wrote in message news:6CCE8C7C-F386-4A40-A449-66EBAF02EF25(a)microsoft.com... On Wednesday, July 23, 2008 2:05 PM Hutt wrote: I failed to mention I am using a nested gridview in application. I failed to mention I am using a nested gridview in application. The second gridview shows the details of the master gridview where I want to display totals. My goal is to show hierarchial data with subtotals at major intervals. Will the repeater accomplish this task? Thanks. -- Hutty "Eliyahu Goldin" wrote: Submitted via EggHeadCafe - Software Developer Portal of Choice WPF Reflection Effect http://www.eggheadcafe.com/tutorials/aspnet/8cc84aa8-3b44-4037-beab-49bd76e20b9b/wpf-reflection-effect.aspx
From: Gregory A. Beamer on 13 Apr 2010 11:42
"rajiv gandhir" wrote in message news:201041371638apssahyd(a)gmail.com... > I have searched the net but have been unable to find a solution to > subtotaling in a gridview. I have a gridview that is bounded to > sqldatasource > where I would like to subtotal rows throughout the gridview based on > column > value "Type". > I am using VB.NET. You have two choices in ASP.NET (actually any .NET) 1. Filter the results prior to binding. This means calculating subtotals and making them a new field before you bind 2. Intercepting the binding event and adding the subtotals. Either will work. I prefer the first if it is every row. And you have two choices on that one: 1. Refactor the query to add subtotal (if per row subtotal is the goal this works well) 2. Refactor the data object to add subtotal On the second point, you can add a column to a DataSet (if used) or have the object with a subtotal field that is automatically calculated by the "domain model" data object. If none of this makes sense, you need to google the basics of domain modeling or DataSets, and possibly the binding events in the Grid you are using. -- Peace and Grace, Greg Twitter: @gbworld Blog: http://gregorybeamer.spaces.live.com ************************************************ | Think outside the box! | ************************************************ |