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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:57:36+00:00 2026-05-14T20:57:36+00:00

There are three column in the datatable A,B and C . Now each column

  • 0

There are three column in the datatable A,B and C. Now each column is type of decimal. Now I am doing like dt.Columns["A"].Expression="B+C"; to make addition of Column B’s record and column C’s record. Now if there is any value of B or C is null then addition of B and C will be null like B’s value is 3 and C’s value is null for first row then B+C(3+null) will be null which is not appropriate, the result of addition should be 3.If I replace 0 instead of null then it will be ok.But whereever there is null value in the records it should be remain it is and it should not be replaced by 0.That is null value should not be replaced by 0 and when addition of null value is done with any decimal value null value should be considered as 0.

Is it possible,how can we do this ?

EDIT
See the following answer
where
dt.Rows[0]["B"] = DBNull.Value;
but I have problem like according to my code I can not assign DBNull.Value directly dt.Rows[0]["B"] = DBNull.Value; I have to store it in one variable of type object like
Object obj;
obj=DBNull.Value
and then that value goes to the table.Then it gives error like null value can not be stored to the column B.

  • 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-05-14T20:57:37+00:00Added an answer on May 14, 2026 at 8:57 pm

    Try something like this

    dt.Columns["A"].Expression = "ISNULL(B, 0) + ISNULL(C, 0)";
    

    Full working test:

    DataTable dt = new DataTable();
    dt.Columns.Add("A", typeof(decimal));
    dt.Columns.Add("B", typeof(decimal));
    dt.Columns.Add("C", typeof(decimal));
    
    dt.Rows.Add();
    dt.Rows[0]["B"] = DBNull.Value;
    dt.Rows[0]["C"] = 3;
    
    dt.Columns["A"].Expression = "ISNULL(B, 0) + ISNULL(C, 0)";
    Console.WriteLine(dt.Rows[0]["A"]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 460k
  • Answers 461k
  • 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
  • Editorial Team
    Editorial Team added an answer line = [item for item in open('C:\chiptext.txt', 'r').read().split(' ') if… May 15, 2026 at 11:56 pm
  • Editorial Team
    Editorial Team added an answer You should be able to override it like so... var… May 15, 2026 at 11:56 pm
  • Editorial Team
    Editorial Team added an answer I have been using GWT for several years. I have… May 15, 2026 at 11:56 pm

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.