Question : How can I specify decimal places in aspx gridview with autogenerated columns

I have a gridview with autogeneratecolumns = true. That is because I am returning a variable number of columns. Despite this the final four columns remain the same and I would like to be able to specify the number of decimal places for these four columns. Is there either a way I can insert columns or specify the decimal places of these four columns at runtime?
thanks
Verdy

Answer : How can I specify decimal places in aspx gridview with autogenerated columns

Hi! Do it something like this. In your RowDataBound event of your gridview.
1:
2:
3:
4:
5:
6:
7:
8:
9:
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //assuming the value you want to format is in cell 0
            string fomattedText = string.Format("{0:N2}", e.Row.Cells[0].Text);
            e.Row.Cells[0].Text = fomattedText;
        }
    }
Random Solutions  
 
programming4us programming4us