如果字符串很长,如何以适当的格式在gridview中显示文本框值 [英] how to display textbox value in gridview in proper format if string is long

查看:53
本文介绍了如果字符串很长,如何以适当的格式在gridview中显示文本框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello先生,

我有2个DropdownList和1个TextBox.DropdownList1用于StartTime,DropdownList2用于EndTime,Textbox用于TaskDescription。

我已经制作了表格在sqlserver.in中,TaskDescription是varchar(5000)。

我有一个gridview用于显示这3个值。



Hello Sir,
I have 2 DropdownList and 1 TextBox.DropdownList1 is for StartTime,DropdownList2 is for EndTime and Textbox is for TaskDescription.
I have made table for that in sqlserver.in that TaskDescription is varchar(5000).
I have one gridview for display this 3 value.

<asp:GridView ID="grdView" runat="server" CssClass="table table-bordered" AutoGenerateColumns="False" TabIndex="1" Width="100%" GridLines="Vertical" OnRowCreated="grdView_RowCreated" OnRowDataBound="grdView_RowDataBound">
                                   <Columns>
                                       <asp:BoundField  HeaderText="#"/>
                                       <asp:BoundField DataField="LoginDate" HeaderText="TimeSheet Date" SortExpression="LoginDate" />
                                       <asp:BoundField DataField="TimeIn" HeaderText="Start Time" SortExpression="TimeIn" />
                                       <asp:BoundField DataField="TimeOut" HeaderText="End Time" SortExpression="TimeOut" />
                                       <asp:BoundField DataField="TaskDescription" HeaderText="Task Description" SortExpression="TaskDescription"  />
                                       <asp:BoundField DataField="TimeSpent" HeaderText="Time Spent" SortExpression="TimeSpent" />
                                       <asp:BoundField DataField="EmployeeId" HeaderText="EmployeeId" SortExpression="EmployeeId" Visible="false"/>
                                   </Columns>
                               </asp:GridView>







现在我的问题是如果我们进入一些长字符串进入TextBox(TaskDescription),这是显示,但我想要如果我在文本框中输入长字符串,所以在gridview中字符串显示相同的长度所以我的gridview变得很长只是我想要如果字符串很长那个时间字符串将如此轻松地包裹可以显示。




Now My problem is If we enter some long string into TextBox(TaskDescription),this is display but i want If i enter long string into textbox so in gridview that string display same length so my gridview become long just i want that if string is long that time string will wrap so easly can display.

推荐答案

查看 AutoSizeRowsMo​​de

Check out for AutoSizeRowsMode
dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCells;




还设置以下属性:

1.将 AutoSizeRowsMo​​de 设置为 AllCells

2. DataGridView.DefaultCellStyle.WrapMode DataGridViewTriState.True

3.如果它不起作用那么你可以使用:



Also set the following properties :
1. Set the AutoSizeRowsMode to AllCells
2. DataGridView.DefaultCellStyle.WrapMode to DataGridViewTriState.True
3. If it does'nt work then you can use :

<asp:GridView>
   <RowStyle HorizontalAlign="Right" />
</asp:GridView>





(您也可以替换t他是水平对齐属性)



(You can also Replace the horizontal alignment property)


这篇关于如果字符串很长,如何以适当的格式在gridview中显示文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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