[英]Column width in gridview
所以我嘗試在7個地方定義模板字段ControlStyle-Width
( ControlStyle-Width
, ItemStyle-Width
, HeaderStyle-Width
, ControlStyle Width
, ItemStyle Width
, TextBox Width
,最后是css
),但是它仍然包裹了內容( “ 1400 kr”)。 這是怎么回事
<asp:TemplateField HeaderText="Totalt" ControlStyle-Width="100" ItemStyle-Width="100" ItemStyle-Wrap="True" HeaderStyle-Width="100" ControlStyle-CssClass="wide">
<ItemTemplate>
<asp:TextBox ID="tbTotalPrice" runat = server ReadOnly="true" Width="100px"></asp:TextBox>
</ItemTemplate>
<ControlStyle Width="100px" />
<ItemStyle HorizontalAlign="Right" Width="100px" />
</asp:TemplateField>
樣式表:
.wide {
width: 120px;
column-width: 120px;
}
確保您沒有提供Gridview的總寬度。 如果已給出Gridview的總寬度,則將其刪除。
另外,由於您已經定義了手動列寬,因此無需為“項模板”提供類。
使用列標簽代替ItemTemplate標簽,然后設置列寬。 您還可以使用style =“ white-space:nowrap; overflow:hidden;” 如果它大於列寬,它將截斷文本。 您可以使用style =“ overflow:hidden;” 如果您希望將文本換行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.