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 8101579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:00:44+00:00 2026-06-05T23:00:44+00:00

I need to add some total rows to a table. The code I am

  • 0

I need to add some “total rows” to a table. The code I am currently using for the sub totals is:

DataRow shRow = ds.Tables[0].NewRow();
shRow["a"] = "SubHead";
shRow["b"] = "Wheel Subs";
shRow["c"] = totalWheels;

Since I need totals and sub totals and sub sub totals I have to cut and paste this code (changing the values) for each new sub total.

I would like to have a function that takes the current table and values and adds the new row.
Something like:

public DataRow SubRow(DataTable ResultsTable, string SubHead, string SubHeader, string SubHeadValue)

That would then update the table in the main function.

Thanks for any help.
I just can’t ‘pass’ the table to and from the new function.

  • 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. Editorial Team
    Editorial Team
    2026-06-05T23:00:46+00:00Added an answer on June 5, 2026 at 11:00 pm

    Whats wrong with that?

    public DataRow SubRow(DataTable resultsTable, string subHead, string subHeader, string subHeadValue)
    {
        DataRow shRow = resultsTable.NewRow();
        shRow["a"] = subHead;
        shRow["b"] = subHeader;
        shRow["c"] = subHeadValue;
        return shRow;
    }
    

    Usage:

    DataRow shRow = SubRow(ds.Tables[0], "SubHead", "Wheel Subs", totalWheels);
    

    By the way, this will not add the row to the table, but only create a row that can fit into the table appropriately. If you actually want to ADD the row to the table, you can do:

    DataRow row = ds.Tables[0].Rows.Add("SubHead", "Wheel Subs", totalWheels);
    

    That will add a row with the given values to the Add method to the datatable, and return the row that has been added.

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

Sidebar

Related Questions

I need to add some lightweight syntactic sugar to JavaScript source code, and process
Total Novice here. I have some list items. I need to add a class
I need to add some functionality to the jQuery UI autosearch function. The problem
I need to add some accordian style expand/collapse handles to a series of parent
i need to add some text DIV's on each slide of a Nivoslider. I
i need to add some functionality to an asp.net application that allows the positioning
i'm writing an application that need to add some events to a calendar in
I have a form and I need to add some data from database before
In One of my application i need to add some image in video. so
After inserting new html to DOM,I need to add some listeners to it. But

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.