First include the AJAX Toolkit controls in your project and add the below code in your form (ASPX file)
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
Next drag and drop the text box, script manager and FilteredTextBoxExtender
Add the below code
Display the currency(US$) format in textbox in code behind
TextBox1.Text = String.Format("{0:C2}", (ds.Tables[0].Rows[0]["Price"]));
The price will display as “$250,200,000.00”
At the time of inserting the Price in DB, remove the $ and , using the below function and insert into table
public string removeFormat(string amount)
{
string replace;
replace = amount.Replace("$", "");
replace = replace.Replace(",", "");
return replace;
}
Decimal price = Convert.ToDecimal(removeFormat(TextBox1.Text));
I am very enjoyed for this blog. Its an informative topic. It help me very much to solve some problems. Its opportunity are so fantastic and working style so speedy.http://psiprograms.com
ReplyDelete