Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a datagrid with some columns. One of it has a big width. At runtime I see the grid with a scrollbar and I can scroll left an right to see the whole grid.
I like to have that the grid has no scrollbar and each row is wrapped in a new line.
Is this somehow possible?
Posted
Comments
Sandeep Mewara 26-Feb-13 11:20am    
Have fixed width of the columns as per need to avoid scroll. By default contents should get wrapped, if not, put wrapping for the text.
Sergey Alexandrovich Kryukov 26-Feb-13 14:24pm    
Right. Believe or not, I answered the question, please see.
—SA
Sergey Alexandrovich Kryukov 26-Feb-13 14:17pm    
Wrapped row? Not wrapped cell content?
—SA

I am pretty much sure that none of the grid views can do it: it's beyond the nature of such controls.

All you can do is developing of your own custom control, but I don't advices it, it would strongly defeat the purpose of the grid view and would greatly confuse the users, including yourself. Just imagine it's look. It only seems to you that you "like to have". Draw it on paper, screen, or in your imagination, and you will quickly see that you won't like it at all. Better think on the design of narrower grid and perhaps some kind of "drill down", on click, context menu or somehow.

—SA
 
Share this answer
 
v2
CSS
Hi

You can wrap the text in grid.

You have to follow the below steps: 


1. GridView width should be in precentage (Width="100%")
2. In the same way you have to give column width (ItemStyle-Width="10%" HeaderStyle-Width="10%")
3. Set ItemStyle-Wrap="true" for wrapping the text
4. Sum of all cilumns width must be equal to 100%

Example
XML
<asp:GridView ID="gvDetails" runat="server" AutoGenerateColumns="False"
        GridLines="Vertical" Width="100%">
        <Columns>
            <asp:TemplateField HeaderText="Remarks" ItemStyle-Wrap="true" ItemStyle-Width="80%" HeaderStyle-Width="10%">
                <ItemTemplate>
                    <asp:Label ID="lblRemarks" runat="server" Text='<%# Bind("REMARKS") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Customer" ItemStyle-Width="10%" HeaderStyle-Width="10%">
                <ItemTemplate>
                    <asp:Label ID="lblCustomerName" runat="server" Text='<%# Bind("CUSTOMERNAME") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Status" ItemStyle-Width="10%" HeaderStyle-Width="6%">
                <ItemTemplate>
                    <asp:Label ID="lblSts" runat="server" Text='<%# Bind("Status") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>


Regards
Willington
 
Share this answer
 
Thanks for your answers.
The idea with wrapping the text I don't like it because of the row height.
Either I have a fixed row height three times higher than normal to show all contents or
I have auto row height then I have a bumpy view depending if description column is wrapped.

This example shows what I like to have:

>>
 Pos  Quantity  Unitprice  Unit  Discount  PO Number Total 
Description
 1 3 5.00 Pc 50% 4512345678  7.50
Chewingum
 2 2 2.00 Pc 10% 4587654321  3.60
Lollypop sweet sour and cherry curry hot style taste


I will try to realize it by duplicate each row, make DataGridCells alternating visible or not
and group rows by Pos column.
Any criticism and suggestion are welcome
 
Share this answer
 

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