Error: No overload for method ToString takes 1 arguments for thousand separator in ASP.Net

Last Reply on Jun 12, 2017 08:53 AM By dharmendr

Posted on Jun 12, 2017 08:30 AM


I put label in page that bind number from database I want use thousand seprator for this label so I wrote below code in behind code:

LblkolP.Text = toPersianNumber(_dr["TotalPrice"].ToString("N0"));

but below error:

Server Error in '/' Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS1501: No overload for method 'ToString' takes 1 arguments Source Error:

Line 57:                     Lblejare.Text = toPersianNumber(_dr["ejare"].ToString());
Line 58:                     Lblvadie.Text = toPersianNumber(_dr["rahn"].ToString());
Line 59:                     LblkolP.Text = toPersianNumber(_dr["TotalPrice"].ToString("N0"));



Posted on Jun 12, 2017 08:42 AM

ok I know it but that code was different here I want label dispalay numer from database and codes are different:

link codes was:

int total = Convert.ToInt32(totalPrice);
lbltotal.Text = total.ToString("N0"); //1,000,000,000
lbltotal.Text = total.ToString("N"); //1,000,000,000.00

but here is:

LblkolP.Text = toPersianNumber(_dr["TotalPrice"].ToString("N0"));

bind from database and display in label

Posted on Jun 12, 2017 08:53 AM

First you need to convert the value to int or decimal and then convert to ToString with argument.

LblkolP.Text = toPersianNumber(Convert.ToInt32(_dr["TotalPrice"]).ToString("N0"));