Friday, March 4, 2011

How do I manually add additional rows to the bottom of an ASP.NET gridview?

I have a situation where I'm populating a gridview with a bound data source, and want two additional rows at the very bottom; one to show the sum of values in the columns and one to show the average of values in the columns. I can quite easily calculate these values by aggregating information taken from the rowDataBound event, but don't know how to go about manually adding the additional two rows to the gridview. Any help much appreciated.

From stackoverflow
  • You can use the Footer just like you use Headers in gridview.. whereas another solution is use a query in such way:

    query 1 : ur original qry

    UNION

    query 2 : ur query which contains sum

    (This applies only if you dont apply paging to ur grid)

  • If it's a single row of information you can use summary footer. See Displaying Summary Information in the GridView's Footer.

    alt text

    If you want two additional rows, you can stuff rows into an IList. At the business logic layer, you can add more rows to the list returned by DAL.

0 comments:

Post a Comment