Wrap long text in GridView and report viewer in ASP.Net

Last Reply 6 months ago By kalpesh

Posted 6 months ago

What i want, if the text is too long to fit as per the defined width, the text should be wrapped in next row. I don’t want to expand the column width to accommodate this text in one row. In other words, I want to wrap the text in next row if the text inside this columns exceeded the width of the column defined in gridview and reportviewer

Posted 6 months ago
Hi @DiemHuong,
Please try the following

Wrap long text in GridView Column in ASP.Net

It might help you.

Cheers Andrea.

Posted 6 months ago

How you are setting the grid colums Width. Just assign the ItemStyle-Width like ItemStyle-Width="100px" to set the BoundField or TemplateField.

HTML

<asp:GridView ID="GVDetails" runat="server"   AutoGenerateColumns="false">
    <Columns>
        <asp:BoundField DataField="Description" ItemStyle-Width="100px" HeaderText="Description" />
        <asp:TemplateField ItemStyle-Width="100px"  HeaderText="Description">
            <ItemTemplate>
                <asp:Label ID="lblDescription" runat="server" Text='<%#Eval("Description") %>'>                        
                </asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

Output

For ReportViewer go to your RDLC report and Right Click on Field name => Select Text Box Properties from Options => Checked Allow height to increase.

OutPut

I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html