Several Methods to fix. net gridview column width

Source: Internet
Author: User

1. In the edit column, you can directly set the column width! If you don't want the cell content to increase the size of the cell, add a style.
<Style> table {table-layout: fixed} </style>, which means that each column is fixed to the style originally set and does not change. The excess part is hidden.
2. You can set the attribute <HeaderStyle Width = "8%"> </HeaderStyle> of a column under the editing column in The gridview to display the display by of the screen.
3. You must have set the height attribute of the gridview. In this way, you have fixed the height of the gridview. If the data is insufficient, the height of the gridview will not change, you can delete the height attribute of the gridview. If the layout is affected, you can
Add the following code to the RowDataBound data of the gridview:
E. Row. Attributes. Add ("style", "height: 43px"); To set the Row height
The automatically generated GridView cannot modify the column width. You can set it using ItemStyle.

<Asp: GridView ID = "GridView1" runat = "server" AutoGenerateColumns = "False">
<Columns>
<Asp: BoundField DataField = "id">
<ItemStyle Width = "100px"/>
</Asp: BoundField>
</Columns>
</Asp: GridView>
4. 1. Set the Width and Height of the column in GridView> Columns> HeaderStyle, GridView> Columns> ItemStyle> Height and Width.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.