Resizing GridViews Columns

If your Gridview is not behaving as it should (the widths of the columns are out of control), this method below should help you Fix that.

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
       foreach (TableCell myCell in e.Row.Cells)
        {
            // Takes cares if wrapping the long Cells
             myCell.Style.Add("word-break", "break-all");
            // set the height of my Cells
             myCell.Style.Add("height", "50px");
        }

       // set each with based on the maximun size of each data
       // In this case i have 6 columns on my gridview that i have to fit in "800px"

       GridView1.Columns[0].ItemStyle.Width = 30;
       GridView1.Columns[1].ItemStyle.Width = 30;
       GridView1.Columns[2].ItemStyle.Width = 100;
       GridView1.Columns[3].ItemStyle.Width = 50;
       GridView1.Columns[4].ItemStyle.Width = 80;
       GridView1.Columns[5].ItemStyle.Width = 200;
    }