Gridview-Can't adjust column width

Discussion in 'ASP .Net' started by msch-prv@bluewin.ch, Jul 25, 2006.

  1. Guest

    I have difficulties adjusting the column width of a gridview control.
    The column width changes appear in the design grid, but at run-time the
    width changes back to what I presume are the grid's default settings.

    Idem for the pager settings: the page settings are spread over the grid
    width (justified) instead of being grouped on the left hand side. I
    tried changing various settings and adding some CSS to no avail.

    Thanks for any suggestions Mark

    Code:
    <div style=" background-color: #CCFFFF; padding: 0.5em; border:1px
    solid; font-size: small; ">

    <asp:GridView ID="grdTasks1" AllowPaging="True"
    AutoGenerateColumns="False"
    EmptyDataText="No records found" PageSize="5"
    runat="server" OnPageIndexChanging="grdAct_PageIndexChanging"
    AllowSorting="True"
    DataKeyNames="ActID,ActDueDay"
    OnSorting="grdAct_Sorting"
    OnSelectedIndexChanged="grdAct_SelectedIndexChanged"
    CaptionAlign="Left" Caption="Grid" GridLines="None"
    CellPadding="2" PagerStyle-HorizontalAlign="Left">

    <Columns>

    <asp:BoundField DataField="PrjDesc1" HeaderText="Project"
    HeaderStyle-Width="25px" SortExpression="PrjDesc1" />

    <asp:BoundField DataField="ActAssgnN" HeaderText="Assignee"
    HeaderStyle-Width="25px" SortExpression="ActAssgnN" />

    <asp:BoundField DataField="ActStat" HeaderText="Status"
    SortExpression="ActStat" />

    <asp:BoundField DataField="FromName" HeaderText="From"
    SortExpression="FromName" />

    <asp:BoundField DataField="ActDueDay" HeaderText="Due Day"
    SortExpression="ActDueDay" />

    <asp:BoundField DataField="ActPrio" HeaderText="Priority"
    SortExpression="ActPrio" />

    </Columns>

    <PagerSettings Mode="NumericFirstLast" />
    </asp:GridView>
    </div>
    , Jul 25, 2006
    #1
    1. Advertising

  2. Try css rule tablelayout:fixed

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]

    <> wrote in message
    news:...
    >I have difficulties adjusting the column width of a gridview control.
    > The column width changes appear in the design grid, but at run-time the
    > width changes back to what I presume are the grid's default settings.
    >
    > Idem for the pager settings: the page settings are spread over the grid
    > width (justified) instead of being grouped on the left hand side. I
    > tried changing various settings and adding some CSS to no avail.
    >
    > Thanks for any suggestions Mark
    >
    > Code:
    > <div style=" background-color: #CCFFFF; padding: 0.5em; border:1px
    > solid; font-size: small; ">
    >
    > <asp:GridView ID="grdTasks1" AllowPaging="True"
    > AutoGenerateColumns="False"
    > EmptyDataText="No records found" PageSize="5"
    > runat="server" OnPageIndexChanging="grdAct_PageIndexChanging"
    > AllowSorting="True"
    > DataKeyNames="ActID,ActDueDay"
    > OnSorting="grdAct_Sorting"
    > OnSelectedIndexChanged="grdAct_SelectedIndexChanged"
    > CaptionAlign="Left" Caption="Grid" GridLines="None"
    > CellPadding="2" PagerStyle-HorizontalAlign="Left">
    >
    > <Columns>
    >
    > <asp:BoundField DataField="PrjDesc1" HeaderText="Project"
    > HeaderStyle-Width="25px" SortExpression="PrjDesc1" />
    >
    > <asp:BoundField DataField="ActAssgnN" HeaderText="Assignee"
    > HeaderStyle-Width="25px" SortExpression="ActAssgnN" />
    >
    > <asp:BoundField DataField="ActStat" HeaderText="Status"
    > SortExpression="ActStat" />
    >
    > <asp:BoundField DataField="FromName" HeaderText="From"
    > SortExpression="FromName" />
    >
    > <asp:BoundField DataField="ActDueDay" HeaderText="Due Day"
    > SortExpression="ActDueDay" />
    >
    > <asp:BoundField DataField="ActPrio" HeaderText="Priority"
    > SortExpression="ActPrio" />
    >
    > </Columns>
    >
    > <PagerSettings Mode="NumericFirstLast" />
    > </asp:GridView>
    > </div>
    >
    Eliyahu Goldin, Jul 26, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert S
    Replies:
    8
    Views:
    24,712
    Jonathan N. Little
    Jul 11, 2006
  2. Replies:
    0
    Views:
    913
  3. Carl Howarth

    DG Column Width vs Table Column Width

    Carl Howarth, Oct 22, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    253
    Eliyahu Goldin
    Oct 24, 2004
  4. Greg P.

    ItemStyle.Width doens't adjust the size of a column?

    Greg P., Mar 28, 2007, in forum: ASP .Net Web Controls
    Replies:
    14
    Views:
    321
    Paul Shapiro
    Feb 11, 2008
  5. Replies:
    1
    Views:
    1,515
Loading...

Share This Page