Hi,
I have a dynamic gridview and formatting needs to be applied for certain columns.
Code:
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.
Please correct me if I'm doing something wrong.
AjeeshPosted Jan 14, 2018, 8:32 PM
Suraj KumarPosted Jan 12, 2018, 2:33 AM
Suraj KumarPosted Jan 12, 2018, 2:32 AM
Piyush PansuriyaPosted Jan 12, 2018, 2:29 AM