如何设置Gridview的BouldField列的最大宽度?

| 我有一个设计缺陷,非常需要帮助,因为我对.NET相当陌生。 我的页面上有一个GridView,我的目标是限制每列的最大宽度。下面是代码:
<asp:GridView ID=\"GridViewMessages\" runat=\"server\" AllowPaging=\"True\" AllowSorting=\"True\"
        AutoGenerateColumns=\"False\" CellPadding=\"4\" DataKeyNames=\"ID\" DataSourceID=\"LinqDataSourceMessages\"
        ForeColor=\"#333333\" GridLines=\"None\" Width=\"600px\">
        <AlternatingRowStyle BackColor=\"White\" ForeColor=\"#284775\" />
        <Columns>
            <asp:CommandField ShowDeleteButton=\"true\" ButtonType=\"Button\" ControlStyle-BackColor=\"Red\" />
            <asp:CommandField ShowEditButton=\"True\" ShowSelectButton=\"True\" />
            <asp:BoundField DataField=\"FromUser\" HeaderText=\"Pengirim\" InsertVisible=\"False\"
                ReadOnly=\"True\" SortExpression=\"FromUser\" ItemStyle-Width=\"10%\" ItemStyle-Wrap=\"false\" />
            <asp:BoundField DataField=\"ToUser\" HeaderText=\"Penerima\" InsertVisible=\"False\" ReadOnly=\"True\"
                SortExpression=\"ToUser\" ItemStyle-Width=\"10%\" ItemStyle-Wrap=\"false\" />
            <asp:BoundField DataField=\"Message1\" HeaderText=\"Pesan\" InsertVisible=\"False\" ReadOnly=\"True\"
                SortExpression=\"Message1\" HeaderStyle-Width=\"50%\" HeaderStyle-Wrap=\"false\" ItemStyle-Width=\"50%\" ItemStyle-Wrap=\"false\" />
            <asp:CheckBoxField DataField=\"IsDone\" HeaderText=\"Selesai?\" SortExpression=\"IsDone\"
                ReadOnly=\"false\" ItemStyle-Width=\"10%\" ItemStyle-Wrap=\"false\" />
            <asp:BoundField DataField=\"DateCreated\" HeaderText=\"Tanggal Buat\" InsertVisible=\"False\"
                ReadOnly=\"True\" SortExpression=\"DateCreated\" ItemStyle-Width=\"20%\" ItemStyle-Wrap=\"false\" />
        </Columns>
        <EditRowStyle BackColor=\"#999999\" />
        <FooterStyle BackColor=\"#5D7B9D\" Font-Bold=\"True\" ForeColor=\"White\" />
        <HeaderStyle BackColor=\"#5D7B9D\" Font-Bold=\"True\" ForeColor=\"White\" />
        <PagerStyle BackColor=\"#284775\" ForeColor=\"White\" HorizontalAlign=\"Center\" />
        <RowStyle BackColor=\"#F7F6F3\" ForeColor=\"#333333\" />
        <SelectedRowStyle BackColor=\"#E2DED6\" Font-Bold=\"True\" ForeColor=\"#333333\" />
        <SortedAscendingCellStyle BackColor=\"#E9E7E2\" />
        <SortedAscendingHeaderStyle BackColor=\"#506C8C\" />
        <SortedDescendingCellStyle BackColor=\"#FFFDF8\" />
        <SortedDescendingHeaderStyle BackColor=\"#6F8DAE\" />
    </asp:GridView>
即使我使用
ItemStyle-Width=\"300px\"
,但如果数据长度大于300px也无法使用。仅当每个数据的长度小于设置的宽度时,一切似乎才起作用。 你们知道我该如何改变这个设计问题? 提前非常感谢您。     
已邀请:
我想这是因为网格是用HTML表呈现的。 在一个表中,所包含的总是获胜。如果列中的文本大于您声明的文本,则该列将被展开。     

要回复问题请先登录注册