Hi All,
I want try to set format of datagridview column through below code
but its showing error {"Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index"}
InitializeComponent();
this.dataGridView1.Columns[8].DefaultCellStyle.Format = "0.0";

Vignesh ManiRank #98 · 22.1K reputationPosted Jun 30, 2016, 1:56 PM EDT
protected void GridView_DataBound(Object sender, EventArgs e) { GridView grid = (GridView)sender; BoundField col = (BoundField)grid.Columns[1]; int numDecimals = 2; // from database col.DataFormatString = "{0:N" + numDecimals + "}"; }Feroz KhanRank #3,748 · 395 reputationPosted Jul 2, 2016, 5:55 AM EDT