我一直在尋找一個答案,並沒有找到我在找什麼。我有一個5列的GridView。其中一列是用「 」代替「」的非常長的字符串。我需要能夠固定列的寬度,並使字符包裝處理字符串直到它結束。我已經嘗試了gridview上的所有屬性來獲得我需要的東西,但跨度總是橫向伸展並且從不包裝。這裏是我的GridView控件代碼修復Gridview與Word Wrap的寬度列
<asp:GridView ID="resultsGrid" AutoGenerateColumns="False" runat="server" AllowPaging="True"
AllowSorting="True" PageSize="20" OnPageIndexChanging="gridView_PageIndexChanging"
OnSorting="gridView_Sorting" PagerSettings-Position="TopAndBottom" PagerStyle-HorizontalAlign="Center">
<PagerSettings Position="TopAndBottom" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<%# Container.DataItemIndex + 1 + "." %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField Visible="false" SortExpression="record_id">
<ItemTemplate>
<asp:Label ID="lblRecordID" runat="server" Text='<%# Bind("RecordID") %>' Visible="false"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Note Type" SortExpression="business_content_type_cd">
<ItemTemplate>
<asp:Label ID="lblNoteType" runat="server" Text='<%# Bind("NoteType") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Author" SortExpression="author_user_name">
<ItemTemplate>
<asp:Label ID="lblAuthor" runat="server" Text='<%# Bind("Author") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Date" SortExpression="content_dttm">
<ItemTemplate>
<asp:Label ID="lblDate" runat="server" Text='<%# Bind("Date") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label Width="100px" ID="lblData" runat="server" Text='<%# Bind("NoteContent") %>'></asp:Label>
<asp:HyperLink ID="linkMore" runat="server" />
</ItemTemplate>
<FooterStyle Wrap="true" Width="100px" />
<HeaderStyle Wrap="true" Width="100px" />
<ItemStyle Wrap="true" Width="100px" />
</asp:TemplateField>
<asp:TemplateField SortExpression="size" Visible="false">
<ItemTemplate>
<asp:Label ID="lblSize" runat="server" Text='<%# Bind("Size") %>' Visible="false"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle HorizontalAlign="Center" />
</asp:GridView>
我沒有什麼,我必須做一個迷,但是客戶希望客戶想要什麼(我需要模擬大型機屏幕的用戶界面)。感謝您的幫助
我已經在我的代碼中那樣做了。我究竟做錯了什麼? – 2011-03-24 15:37:24
我也一直在尋找這個確切的答案,現在2天... – clamchoda 2011-12-09 22:19:39