0

我尝试不同的“属性”:

  • ItemStyle-宽度
  • ControlStyle-宽度
  • HeaderStyle-宽度

我将 ItemStyle-Wrap 设置为“true”。我使用 css 类:

.wraptext
{
    word-wrap:break-word;
    -ms-word-wrap: break-word;
    -moz-word-wrap: break-word;
    -webkit-word-wrap: break-word;
}

它没有帮助我。我的网格视图:

<asp:Panel ID="Panel2" Height="570px" Width="100%" runat="server" ScrollBars="Vertical" BackColor="White">
    <asp:GridView ID="tableResults" runat="server" DataSourceID="sourceDetails"
        AutoGenerateColumns="False" OnDataBound="tableResults_Bound"
        OnRowDataBound = "tableResults_DataBound" DataKeyNames="i_id"
        AutoGenerateDeleteButton="True" OnRowDeleted="tableResults_RowDeleted"
        AutoGenerateEditButton = "True" OnRowUpdating="tableResults_RowUpdating"
        OnRowUpdated="tableResults_RowUpdated" AllowSorting="true" AllowPaging="true" PageSize="150"
        Height="300px" BorderStyle="None" Font-Size="12px">            
        <RowStyle BorderColor="Black" />
      <Columns>          
        <asp:TemplateField HeaderText="Код патча" SortExpression="patchcode" ItemStyle-Width="4%">
            <HeaderStyle Width="4%" />
            <ItemTemplate>
                <asp:Label Width="4%" ID="lblPatchCode" runat="server" Text='<%# Eval("patchcode") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField HeaderStyle-Width="3%" ItemStyle-Width="3%" DataField="i_number" ReadOnly="true" HeaderText="П/п" SortExpression="i_number"/>
        <asp:BoundField HeaderStyle-Width="20%" ItemStyle-CssClass="wraptext" ItemStyle-Width="20%" DataField="s_name" ReadOnly="true" HeaderText="Наименование работы" SortExpression="s_name"/>            
        <asp:TemplateField HeaderText="Статус" SortExpression="status" ItemStyle-Width="7%">
            <HeaderStyle Width="7%" />
            <ItemTemplate>
                <asp:Label ID="lblStatus" runat="server" Text='<%# Eval("status")%>'></asp:Label>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:Label ID="lblStatus" runat="server" Text='<%# Eval("status")%>' Visible = "false"></asp:Label>                     
                <asp:DropDownList AutoPostBack="true" OnSelectedIndexChanged="ddl_OnSelectedIndexChanged"
                    ID="ddlStatuses" runat="server"></asp:DropDownList>
            </EditItemTemplate>
        </asp:TemplateField>             
      </Columns>           
     </asp:GridView>
4

1 回答 1

0

CSS3 word-wrap 属性是一个 CSS3 特性,因此只能在支持 css3 的现代浏览器中工作word-wrap

为了回退到不支持的浏览器,请使用 .NET和page-behindGridView中的方法来打破字母。Evalpublic

于 2013-01-23T05:19:08.473 回答