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

  • SEARCH
  • Home
  • 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

Related Questions

I have a datagrid view which is editable. I'm getting the value of a
I have a DataGrid with a CheckBox column. I show a popup if the
I have a DataGrid in WPF bound to an observable collection. In my UI
I have a datagrid and I want to set the value of a dropdownlist
I have a TextArea and a DataGrid. I've populated the DataGrid with a list
I have a datagrid on my application getting it's data from a database. Which
I'm trying to format some numbers in a column of a DataGrid. I'm getting
I have a datagrid getting its data from the database. This datagrid has a
I have a dynamic Datagrid that I have created. I am creating each column
I have a DataGrid with 4 columns, the first two of them are bound

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.