How to shown format number like this {###,###.##} in GridView?
Thursday, February 28, 2008 5:39:53 PM
<asp:BoundField DataField="DOB" HeaderText="Date Of Birth" HtmlEncode="False" DataFormatString="{0:d}" />
And then implement the backend code like below:(Code VB.NET)
protected void OnRowDataBound(object sender, EventArgs e)
{
GridViewRowEventArgs ea = e as GridViewRowEventArgs;
if (ea.Row.RowType == DataControlRowType.DataRow)
{
DataRowView drv = ea.Row.DataItem as DataRowView;
Object ob = drv["Phone"];
if (!Convert.IsDBNull(ob))
{
Int64 iParsedValue = 0;
if (Int64.TryParse(ob.ToString(), out iParsedValue))
{
TableCell cell = ea.Row.Cells[4];
cell.Text = String.Format(System.Globalization.CultureInfo.CurrentCulture,
"{0:(###) ###-####}", new object[] { iParsedValue });
}
}
}
}






