Introduction to several methods of asp.net GridView column-width fixing-practical tips

Source: Internet
Author: User

1, in the editing column, there is a direct set column width! If you don't want cell content to hold the cell large, add a style
<style>table{table-layout:fixed}</style>, meaning that each column is fixed to the original set style, no longer changes, the excess part of the hidden

2 . You can set the properties of a column under the Edit column in the GridView

3 . You must have set the Height property of the GridView, so that you have fixed the high level of the GridView, and when 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, the following code can be added to the RowDataBound data of the GridView:
E.row.attributes.add ("style", "height:43px"); This sets the line height
The automatically generated GridView cannot modify column widths, and you can use ItemStyle to set

Copy Code code as follows:

<asp:gridview id= "GridView1" runat= "Server" autogeneratecolumns= "False" >
<Columns>
<asp:boundfield datafield= "id" >
<itemstyle width= "100px"/>
</asp:BoundField>
</Columns>
</asp:GridView>

4,
One,
Gridview-->columns---->headerstyle, gridview-->columns---->itemstyle--->height, width, set the width and height of the column.

Second,Sets the Wrap property below the current column to False. It means that you cannot wrap the line automatically. The first step on the internet to search a basket, but found that these results are not what they want. With the second step, I think your problem will be solved.

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.