Click here to Skip to main content
15,905,238 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.NET
<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>



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.
Posted

1 solution

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


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.NET
<asp:GridView>
   <RowStyle HorizontalAlign="Right" />
</asp:GridView>


(You can also Replace the horizontal alignment property)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900