多行文字在GridView控件不工作 [英] multiline text in gridview not working

查看:123
本文介绍了多行文字在GridView控件不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不给多行文本中的GridView细胞

 < ASP:GridView控件ID =GridView1=服务器的AutoGenerateColumns =FALSE的DataKeyNames =类别ID
            的DataSourceID =SqlDataSource1ShowFooter =真AllowPaging =真AllowSorting =真
            每页=5OnRowDataBound =GridView1_RowDataBound>
            <柱体和GT;
                < ASP:的TemplateField的HeaderText =类别IDInsertVisible =FALSESORTEX pression =类别ID>
                    <&ItemTemplate中GT;
                        < ASP:标签ID =lblCategoryID=服务器文本='<%#绑定(类别ID)%>'>< / ASP:标签>
                    < / ItemTemplate中>
                < / ASP:的TemplateField>
                < ASP:的TemplateField的HeaderText =类别名称SORTEX pression =类别名称>
                    <&EditItemTemplate的GT;
                        < ASP:文本框ID =txtCategoryName=服务器文本='<%#绑定(类别名称)%>'>< / ASP:文本框>
                    < / EditItemTemplate中>
                    <&ItemTemplate中GT;
                        < ASP:标签ID =lblCategoryName=服务器文本='<%#绑定(类别名称)%>'>< / ASP:标签>
                    < / ItemTemplate中>
                < / ASP:的TemplateField>
                < ASP:的TemplateField的HeaderText =说明SORTEX pression =说明>
                    <&EditItemTemplate的GT;
                        < ASP:文本框ID =txtDesc=服务器文本='<%#绑定(说明)%GT;'>< / ASP:文本框>
                    < / EditItemTemplate中>
                    <&ItemTemplate中GT;
                        < ASP:标签ID =lblDesc=服务器文本='<%#绑定(说明)%GT;'>< / ASP:标签>
                    < / ItemTemplate中>
                < / ASP:的TemplateField>
            < /专栏>
        < / ASP:GridView的>


解决方案

的文本框都没有的TextMode 设置为。结果
的TextMode 属性设置为上要显示为textarea的文本框。

例如:

 <&EditItemTemplate的GT;
  < ASP:文本框ID =txtCategoryName列=50行=5=服务器的TextMode =多行文本='<%#绑定(类别名称)%>'>&LT ; / ASP:文本框>
< / EditItemTemplate中>

修改

和使烟标,尝试添加一个ItemStyle它,就像这样:

 < ItemStyle换行=真WIDTH =200/>

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>
                    <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" />

这篇关于多行文字在GridView控件不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆