我在 aspx 頁面上使用 VS2019 和 VB。我有一個啟用了編輯的網格視圖。

當您單擊“編輯”時,會出現文本,但所有文本都顯示在一行中并且不會換行(注釋列)。

我使用 ControlStyle 來增加文本框的大小 (400x240),但文本仍然在文本框中居中并且不換行。
我沒有看到換行或對齊的選項。
我該怎么做呢?
<asp:GridView ID="grdgoals" runat="server" AutoGenerateColumns="False" DataSourceID="DS1" Height="225px" Width="1001px" BorderColor="#003960" BorderStyle="Solid" BorderWidth="1px" DataKeyNames="goalid" EmptyDataText="No goals found." Font-Bold="True" Font-Names="Calibri" Font-Overline="False" Font-Size="Medium" Font-Strikeout="False" ForeColor="#00AD86" ShowHeaderWhenEmpty="True" AllowSorting="True" style="margin-right: 21px">
<Columns>
<asp:BoundField DataField="goalid" HeaderText="goalid" ReadOnly="True" SortExpression="goalid" Visible="False" />
<asp:CommandField EditText="EDIT" ShowEditButton="True" ShowHeader="True">
<HeaderStyle BorderColor="#003960" />
<ItemStyle Font-Names="Calibri" Font-Underline="True" ForeColor="#006EAA" HorizontalAlign="Center" BorderColor="#003960" Width="20px" />
</asp:CommandField>
<asp:BoundField DataField="goaltext" HeaderText="Goal" SortExpression="goaltext" ReadOnly="True" >
<HeaderStyle BorderColor="#003960" />
<ItemStyle BorderColor="#003960" Width="250px" />
</asp:BoundField>
<asp:BoundField ConvertEmptyStringToNull="True" DataField="type" HeaderText="Type" ReadOnly="True" >
<ItemStyle Width="70px" />
</asp:BoundField>
<asp:BoundField DataField="progress" HeaderText="Progress %" SortExpression="progress" >
<HeaderStyle BorderColor="#003960" />
<ItemStyle HorizontalAlign="Center" BorderColor="#003960" VerticalAlign="Middle" Width="20px" />
</asp:BoundField>
<asp:BoundField DataField="comments" HeaderText="Comments" SortExpression="comments" ItemStyle-Wrap="true">
<ControlStyle Height="400px" Width="240px" />
<HeaderStyle BorderColor="#003960" />
<ItemStyle BorderColor="#003960" Width="250px" HorizontalAlign="Left" VerticalAlign="Middle" />
</asp:BoundField>
<asp:BoundField DataField="approved" HeaderText="Approved" ReadOnly="True" SortExpression="approved" >
<ItemStyle HorizontalAlign="Center" Width="40px" />
</asp:BoundField>
</Columns>
<EditRowStyle HorizontalAlign="Left" VerticalAlign="Top" />
<HeaderStyle ForeColor="#006EAA" />
</asp:GridView>
我嘗試使用這樣的代碼,但我在網上找到的 EditItemTemplate 但收到一條不支持的訊息。
'>uj5u.com熱心網友回復:
代替使用系結欄位,您可以放入平面簡文本框。
因此,比如說在 GV 之外的區域,在文本框中拖放。
設定文本模式 =
因此,您的文本框將如下所示:
<asp:TextBox ID="TextBox1" runat="server" Height="112px"
TextMode="MultiLine" Width="282px">
</asp:TextBox>
因此,它將創建一個漂亮的更大的文本框。

現在,在 GV 中,洗掉一個資料系結文本框,并使用所謂的模板欄位,如下所示:
<asp:GridView ID="GridView1" runat="server" CssClass="table table-hover" AutoGenerateColumns="False"
DataKeyNames="ID"
DataSourceID="SqlDataSource1">
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
<asp:BoundField DataField="HotelName" HeaderText="HotelName" SortExpression="HotelName" />
<asp:TemplateField HeaderText="Description">
<ItemTemplate>
<asp:Label ID="TextBox1" runat="server" Height="80px"
Text='<%# Bind("Description") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Height="80px"
TextMode="MultiLine" Width="282px"
Text='<%# Bind("Description") %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
因此,請注意我們如何添加模板以及我們想要的“編輯模板”。我們使用文本框 - 而不是標簽。
所以,現在我們將看到/產生這種效果:

因此,您可以放入一個文本框,文本模式 = 多行,然后您應該有一個不錯的文本編輯區域。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/528796.html
標籤:网VB.net视觉工作室 2019
