Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

how to format amount field in gridview in edit mode

$
0
0
Hi,
This is what I was able to format the amount field displaying currency ,but when I got to edit mode,
the formating is not there. so what event I can do the formating , I appreciate a snippet of the code to format in edit mode.

thanks

Bob

protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
{

 if (e.Row.RowType == DataControlRowType.DataRow)
  {
            foreach (TableCell tc in e.Row.Cells)
            {
                DataColumn dc = ((DataRowView)e.Row.DataItem).Row.Table.Columns[((DataControlFieldCell)tc).ContainingField.HeaderText];
                if (dc != null)
              {
                    if (dc.DataType == typeof(decimal))
                    {
                        tc.HorizontalAlign = HorizontalAlign.Right;
                        tc.Text = Decimal.Parse(tc.Text).ToString("C");
	  }
               }
            }
 }
}// end of method


Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>