GridView编辑框 自动换行(转和一点自己的内容)
转自:http://hi.baidu.com/hi9394/blog/item/74d7d554589e49113a2935bc.html
比如GridView或DetailsView中字段a,为string类型,内容是一篇章,但只显示为单行,或在点击编辑后,只显示为一行,没有自动换行。怎么办呢?
1)若该字段不需要被用户篇辑,解决为办法是:“智能标签”-->编辑字段-->选择该字段-->选item style-->设置height及width 为你要的高及宽,wrap为True。
2)若该字段要被用户篇辑,即你已启用“编辑”,解决办法是:“智能标签”-->编辑字段-->选择该字段-->此字段转换为TemplateField。 然后:“智能标签”-->编辑模板-->在下拉单,
选择“EdtiItemTemplate”,设置height及width 为你要的高及宽,TextMode为多行,wrap为True。
选择“ItemTemplate”,设置height及width 为你要的高及宽,wrap为True。
设置后的html代码是:
<asp:TemplateField HeaderText="SendAffairContent"
SortExpression="SendAffairContent">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Height="147px"
Text='<%# Bind("SendAffairContent") %>' Width="574px" Wrap="true" TextMode="MultiLine"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("SendAffairContent") %>'></asp:Label>
</ItemTemplate>
<ControlStyle Height="300px" Width="600px" />
<ItemStyle Width="300px" />
</asp:TemplateField>
SortExpression="SendAffairContent">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Height="147px"
Text='<%# Bind("SendAffairContent") %>' Width="574px" Wrap="true" TextMode="MultiLine"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("SendAffairContent") %>'></asp:Label>
</ItemTemplate>
<ControlStyle Height="300px" Width="600px" />
<ItemStyle Width="300px" />
</asp:TemplateField>
合乎自然而生生不息。。。


浙公网安备 33010602011771号