Click here to Skip to main content
16,021,288 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Members,

I am trying to set a specific header width and item width with wrap = true. The reason so is because I do not want the wrap to reduce the width of the column too much that the data breaks up unnecessarily. The below is not working as the column still wraps to the minimum width it can go.

ASP.NET
<asp:GridView ID="Gridview1" runat="server" AllowSorting="True" AutoGenerateColumns="False" Width="100%"
        ForeColor="#333333">
        <AlternatingRowStyle BackColor="White" />
        <columns>
            <asp:boundfield DataField="Column1" HeaderText="Column1" htmlencode="false" HeaderStyle-Width="100px" ItemStyle-Width="100px"></asp:boundfield>
            <asp:boundfield DataField="Column2" HeaderText="Column1" HeaderStyle-Width="100px" ItemStyle-Width="100px"></asp:boundfield>
            <asp:boundfield DataField="Column2" HeaderText="Column2" HeaderStyle-Width="100px" ItemStyle-Width="100px"></asp:boundfield>
            <asp:boundfield DataField="Column3" HeaderText="Column3" HeaderStyle-Width="100px" ItemStyle-Width="100px"></asp:boundfield>
            <asp:boundfield DataField="Column4" HeaderText="Column4" HeaderStyle-Width="100px" ItemStyle-Width="100px"></asp:boundfield>
            <asp:boundfield DataField="Column5" HeaderText="Column5" HeaderStyle-Width="100px" ItemStyle-Width="100px"></asp:boundfield>

        </columns>
        <EditRowStyle BackColor="#2461BF" />
        <FooterStyle BackColor="#507CD1" Font-Bold="False" ForeColor="Black"/>
        <HeaderStyle BackColor="#507CD1" Font-Bold="False" ForeColor="Black"/>
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#EFF3FB" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="False" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#F5F7FB" />
        <SortedAscendingHeaderStyle BackColor="#6D95E1" />
        <SortedDescendingCellStyle BackColor="#E9EBEF" />
        <SortedDescendingHeaderStyle BackColor="#4870BE" />
    </asp:GridView>
Posted
Updated 30-Sep-15 16:43pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900