protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
for (int i = 0; i < GridView1.HeaderRow.Cells.Count; i++)
string strHeader = GridView1.HeaderRow.Cells[i].Text;
List lstCurrency = new List() { "Price", "Amount" };
bool checkAmount = lstCurrency.Exists(o => strHeader.Equals(o));
if (checkAmount)
e.Row.Cells[i].Text = String.Format("{0:C2}", e.Row.Cells[i].Text);
}
If gridview column header text contains Price or Amount then currency formatting needs to be applied and the above code doesn't work.
Price
Amount
Please correct me if I'm doing something wrong.