Do you mean like another culture than en-US?
if so you can use an IFormatProvider, such as CultureInfo, in such case you could simply change the cultureinfo of the thread you're operating on.
For instance say da-DK!
This culture have , as digit seperator and ; as list seperator and . as thousands seperator instead of the en-US that use . for digits and , for lists.
in this case you'd be able to use
DataTable dtscore = (DataTable)Session["GrdSearch"];
DataView dvscore = dtscore.DefaultView;
DataTable distinctscore = dvscore.ToTable(true, "Score");
distinctscore.Locale = new CultureInfo("da-DK");
ddlscore.DataSource = distinctscore;
ddlscore.DataTextField = "Score";
ddlscore.DataTextFormatString = "{0:0.0%}";
ddlscore.DataBind();
I'm updating solution with a somewhat more explicit implementation to examplify and also updating where the Locale goes as i'd put it on the control not the table by mistake B-]. My page has a single dropdown control with the name DropDown.
using System;
using System.Data;
using System.Globalization;
public partial class DataTableBinding : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable dataTable = GetTable();
DataView dataView = dataTable.DefaultView;
DataTable dataTableDistinct = dataView.ToTable(true, "Score");
dataTableDistinct.Locale = new CultureInfo("da-DK");
DropDown.DataSource = dataTableDistinct;
DropDown.DataTextField = "Score";
DropDown.DataTextFormatString = "{0:0.0%}";
DropDown.DataBind();
DropDown.Items.Insert(0, "ALL");
}
}
private static DataTable GetTable()
{
DataTable dataTable = new DataTable();
dataTable.Columns.Add("Score", typeof(decimal));
DataRow row = dataTable.NewRow();
row["Score"] = 0.98;
dataTable.Rows.Add(row);
row = dataTable.NewRow();
row["Score"] = 0.97;
dataTable.Rows.Add(row);
row = dataTable.NewRow();
row["Score"] = 1.00;
dataTable.Rows.Add(row);
row = dataTable.NewRow();
row["Score"] = 0.85478;
dataTable.Rows.Add(row);
return dataTable;
}