开发者

multiline text in gridview not working

Not giving multiline text in gridview cell

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CategoryID"
            DataSourceID="SqlDataSource1" ShowFooter="true" AllowPaging="True" AllowSorting="True"
            PageSize="5" OnRowDataBound="GridView1_RowDataBound">
            <Columns>                       
                <asp:TemplateField HeaderText="CategoryID" InsertVisible="False" SortExpression="CategoryID">
                    <ItemTemplate>
                        <asp:Label ID="lblCategoryID" runat="server" Text='<%# Bind("CategoryID") %>'></asp:Label>
                    </ItemTemplate>                  
                </asp:TemplateField>
                <asp:TemplateField HeaderText="CategoryName" SortExpression="CategoryName">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtCategoryName" runat="server" Text='<%# Bind("CategoryName") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblCategoryName" runat="server" Text='<%# Bind("CategoryName") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Description" SortExpression="Description">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtDesc" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
                    </EditItemTemplate>
        开发者_JAVA百科            <ItemTemplate>
                        <asp:Label ID="lblDesc" runat="server" Text='<%# Bind("Description") %>'></asp:Label>
                    </ItemTemplate>                               
                </asp:TemplateField>               
            </Columns>
        </asp:GridView>


None of the textboxes have TextMode set to Multiline.
Set the TextMode property to Multiline on the textbox that you want to be displayed as textarea.

e.g:

<EditItemTemplate>                         
  <asp:TextBox ID="txtCategoryName"  Columns="50" Rows="5" runat="server" TextMode="MultiLine" Text='<%# Bind("CategoryName") %>'></asp:TextBox>                     
</EditItemTemplate>

EDIT

And to make the label wrap, try adding an ItemStyle to it, like this:

<ItemStyle Wrap="true" Width="200" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜