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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:54:32+00:00 2026-05-24T01:54:32+00:00

i am trying to add the currency symbol to totalvalue by using following code

  • 0

i am trying to add the currency symbol to totalvalue by using following code

using System.Globalization;

double value;
double totalValue = 0.0;            

foreach (DataRow row in reportData.Rows)
{
    if (double.TryParse(row["value"].ToString(), out value))
    {
        totalValue += value;
        RegionInfo rgi = new RegionInfo("en-UK");
        totalValue += Convert.ToString(string.Format("   CurrencySymbol:               {0}\n", rgi.CurrencySymbol));             
     }
 }

it was giving error can not convert type string to double
would any one pls help me

Modified CODE:

       int count;
      int total = 0;
      double value;

      double totalValue = 0.0;




      foreach (DataRow row in reportData.Rows)
      {
        if (double.TryParse(row["value"].ToString(), out value))
        {
          totalValue += value;


        }

        if (!Overview && int.TryParse(row["mshipssold"].ToString(), out count))
        {
          total += count;
        }
      }
      DataRow totalRow = reportData.NewRow();
      totalRow["mshipType_Name"] = "Total";
      totalRow["mshipssold"] = total;
      totalRow["value"] = totalValue;

      reportData.Rows.Add(totalRow);

      targetChartControl.Series["Value"].Points.DataBindXY(reportData.Rows, "mshipType_Name", reportData.Rows, "value");

      if (!Overview)
      {
        targetChartControl.Series["Quantity"].Points.DataBindXY(reportData.Rows, "mshipType_Name", reportData.Rows, "mshipssold");
      }
    }

Modified code :1

graphenter image description here

I want to show like this £3830 , £2070 , £5090 on the blue bars

and this is my code

   try
    {
    DataTable reportData = KPIData.MembershipSales(StartDate, EndDate, mf);
    Series quantitySeries;
    Series valueSeries = null;
    Title title;
    string area;

    targetChartControl.ChartAreas.Clear();
    targetChartControl.Series.Clear();
    targetChartControl.Titles.Clear();

    area = "Value";
    targetChartControl.ChartAreas.Add(area);
    quantitySeries = targetChartControl.Series.Add(area);
    quantitySeries.ChartArea = area;

    if (!Overview)
    {
      title = targetChartControl.Titles.Add("Membership Sales by Total Contract Value by Type");
      title.Font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
      title.Alignment = ContentAlignment.TopLeft;
      title.DockedToChartArea = area;

      targetChartControl.Titles.Add("").DockedToChartArea = area;
    }

    targetChartControl.Titles.Add("Membership sale values").DockedToChartArea = area;


    if (!Overview)
    {
      area = "Quantity";
      targetChartControl.ChartAreas.Add(area);
      quantitySeries = targetChartControl.Series.Add(area);
      quantitySeries.ChartArea = area;

      title = targetChartControl.Titles.Add("Membership Sales by Quantity");
      title.Font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
      title.Alignment = ContentAlignment.TopLeft;
      title.DockedToChartArea = area;

      targetChartControl.Titles.Add("").DockedToChartArea = area;
      targetChartControl.Titles.Add("Membership sale quantities").DockedToChartArea = area;
    }

    foreach (Title chartTitle in targetChartControl.Titles)
    {
      chartTitle.IsDockedInsideChartArea = false;
    }

    foreach (ChartArea chartArea in targetChartControl.ChartAreas)
    {
      chartArea.Area3DStyle.Enable3D = true;
      chartArea.AxisX.LabelStyle.IsEndLabelVisible = true;
    }

    foreach (Series series in targetChartControl.Series)
    {
      series.ChartType = SeriesChartType.StackedColumn;
      series["ColumnDrawingStyle"] = "SoftEdge";
      series["LabelStyle"] = "Top";

      series.IsValueShownAsLabel = true;
      //          series.CustomProperties = "DrawingStyle=Cylinder";
      series.BackGradientStyle = GradientStyle.DiagonalLeft;
    }

    foreach (Legend legend in targetChartControl.Legends)
    {
      legend.Enabled = false;
    }

    if (reportData == null)
    {
      valueSeries.Points.Clear();
      valueSeries.Points.AddXY("No sales for this time period", 0);

      if (!Overview)
      {
        quantitySeries.Points.Clear();
        quantitySeries.Points.AddXY("No sales for this time period", 0);
      }
    }
    else
    {
      int count;
      int total = 0;
      double value;

      double totalValue = 0.0;




      foreach (DataRow row in reportData.Rows)
      {
        if (double.TryParse(row["value"].ToString(), out value))
        {
          totalValue += value;    

        }

        if (!Overview && int.TryParse(row["mshipssold"].ToString(), out count))
        {
          total += count;
        }
      }

      CultureInfo rgi = new CultureInfo("en-GB");
      string totalcurrency = string.Format(rgi, "{0:C}", totalValue);

      DataRow totalRow = reportData.NewRow();
      totalRow["mshipType_Name"] = "Total";
      totalRow["mshipssold"] = total;
      totalRow["value"] = totalcurrency;

      reportData.Rows.Add(totalRow);

      targetChartControl.Series["Value"].Points.DataBindXY(reportData.Rows, "mshipType_Name", reportData.Rows, "value");

      if (!Overview)
      {
        targetChartControl.Series["Quantity"].Points.DataBindXY(reportData.Rows, "mshipType_Name", reportData.Rows, "mshipssold");
      }
    }
  }
  catch
  {
  }
  • 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-24T01:54:33+00:00Added an answer on May 24, 2026 at 1:54 am

    You need to do your totalling and then convert it to a string.

    double totalValue;
    foreach (DataRow row in reportData.Rows) {
      double value;
      if (double.TryParse(row["value"].ToString(),out value) totalValue+= value;
    }
    CultureInfo rgi = new CultureInfo("en-GB");
    string totalValueCurrency=string.Format(rgi,"{0:c}", totalValue);
    

    In answer to your modified question:

    before before DataRow totalRow = reportData.NewRow(); insert the two lines

    CultureInfo rgi = new CultureInfo("en-GB");
    string totalValueCurrency=string.Format(rgi,"{0:c}", totalValue);
    

    and then change

    totalRow["value"] = totalValue;
    

    to read

    totalRow["value"] = totalValueCurrency;
    

    However this might go horribly wrong if the datatype of your column is not string. You may be better of changing your report to do the formatting for you.

    If you are using Microsoft Chart Control you may want this instead:

    Modify this section of code

    foreach (ChartArea chartArea in targetChartControl.ChartAreas)    {
      chartArea.Area3DStyle.Enable3D = true;
      chartArea.AxisX.LabelStyle.IsEndLabelVisible = true;
      // New Line Here
      chartArea.AxisY.LabelStyle.Format = "C";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying add a tab to my web page that looks like this: Using
I am trying to handle add a custom field to a user profile using
I am trying add on dimension of an array together into a variable using
I'm trying to balance a set of currency values using vb.net. The totals for
I'm trying to use the following code to create a new SalesInvoice based on
trying to add a prefix before bound field <label><input type=radio name=rbGroup value='r<%#((Type)Container.DataItem).ID %>'/><%# ((Type)Container.DataItem).Action
I am trying add value to a mutlidimensional array but I am slightly confused
i'm new to django and im trying add a user using django admin page.
I'm trying add some code at run time to the head element. When I
I'm trying to add currency picker in header of my magento store. I have

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.