I have two gridviews one displaying under the other one. Both gridviews are exactly the same, the only difference with the second gridview is I am not showing the header column. I have tried setting the widths to the exact same values in both gridviews but the columns are not matching up.
I have tried setting with width on the boundfield:
<asp:BoundField DataField="Code" HeaderText="A/C" SortExpression="Code" ItemStyle-Width ="120px"></asp:BoundField>
I have tried setting the width of the column:
gridview.Columns[0].ItemStyle.Width = 120;
I have tried setting the width of the cells:
foreach (TableRow row in gridview.Controls[0].Controls)
{
row.Cells[0].Width = 120;
}
None of the above have worked. The second gridview width (last row in the image) is not displaying the same as the first gridview

First Grid:
<asp:GridView runat="server"
id="gvJobsPerMonth"
CssClass="tblResults"
OnItemDataBound="gvJobsPerMonth_OnItemDataBound"
AllowSorting="true"
OnSortCommand="gvJobsPerMonth_Sort"
DataKeyField="ID"
AutoGenerateColumns="false" >
<HeaderStyle CssClass="tblResultsHeader" />
<AlternatingRowStyle BackColor="#EEEEEE" />
Second Grid:
<asp:GridView runat="server"
id="gvJobsPerMonthTotals"
CssClass="tblResults"
OnItemDataBound="gvJobsPerMonthTotals_OnItemDataBound"
AllowSorting="true"
OnSortCommand="gvJobsPerMonthTotals_Sort"
DataKeyField="ID"
AutoGenerateColumns="false"
ShowHeader="false" >
<HeaderStyle CssClass="tblResultsHeader" />
<AlternatingRowStyle BackColor="#EEEEEE" />
Both grids are using the same CSS classes. The only difference is ShowHeader="false" on the second grid. But even if I set this to true the columns are still showing as different widths
Try this code for your second GridView:
Instead of
120px, use the desired pixel, just after column close</Columns>, like this: