Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 32331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T13:44:45+00:00 2026-05-10T13:44:45+00:00

I have a datagrid getting bound to a dataset, and I want to display

  • 0

I have a datagrid getting bound to a dataset, and I want to display the average result in the footer for a column populated with integers.

The way I figure, there’s 2 ways I can think of:

1.’Use the Source, Luke’
In the code where I’m calling DataGrid.DataBind(), use the DataTable.Compute() method (or in my case DataSet.DataTable(0).Compute()). For example:

Dim strAverage = DataTable.Compute('Avg(ColumnName)', '')   

But once I have this, how can I insert it into the footer?

2.’Bound for Glory’
Using the DataGrid.ItemDataBound event, and calculating a running total from every ListItemType.Item and ListItemType.AlternatingItem, finally displaying in ListItemType.Footer. For example:

Select Case e.Item.ItemType     Case ListItemType.Item, ListItemType.AlternatingItem         runningTotal += CInt(e.Item.Cells(2).Text)     Case ListItemType.Footer         e.Item.Cells(2).Text = runningTotal/DataGrid.Items.Count End Select 

This just feels wrong, plus I would have to make sure the runningTotal is reset on every DataBind.

Is there a better way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T13:44:46+00:00Added an answer on May 10, 2026 at 1:44 pm

    I don’t know if either are necessarily better, but two alternate ways would be:

    1. Manually run through the table once you hit the footer and calculate from the on-screen text
    2. Manually retrieve the data and do the calculation separately from the bind

    Of course, #2 sort of offsets the advantages of data binding (assuming that’s what you’re doing).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 69k
  • Answers 69k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer There are some build runner plugins for TeamCity and you… May 11, 2026 at 12:36 pm
  • added an answer The button colors probably date back to the experiments at… May 11, 2026 at 12:36 pm
  • added an answer EDIT: I added a root node to the xml. and… May 11, 2026 at 12:36 pm

Related Questions

I have a datagrid, populated as shown below. When the user clicks on a
I have a DataGrid where each column has a SortExpression. I would like the
I have a DataGrid, populated with objects in an ArrayCollection. After updating one of
I have a DataGrid, with an ItemTemplate that has an image and label. In
I have a page where I have to modify variables which are strings with
I'm getting into ASP.NET (C# - I know it doesn't matter for this particular
At the risk of being downmodded, I want to ask what the best mechanism

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.