make multiline gridview

Posted on 2007-10-20
Last Modified: 2012-06-27
Hello sir
i am facing a  a problem in my grid and trying to explain with some points
1.Data comming from database in gridview database size of string is declare 35
3.and when data comes in gridview our gridview cell expands and the design of page become very poor

What i want
just want to make cells of gridview multiline i.e if long string come then cell do not expand but line become multiline

kindly help

Question by:HanuSoftware
    LVL 5

    Expert Comment

    On the GridView Edit the Column than your needing to fix the width of the column and make the cell word-wrap.

    <asp:BoundField DataField="title" HeaderText="Title" SortExpression="title" >
        <ItemStyle Width="150px" Wrap="True" />

    Robert Fidler
    Springfield, Missouri

    Author Comment


    i am trying to implement it but it is not working i am sending my code plese examine it

    <asp:GridView ID="title" runat="server" AutoGenerateColumns="false">
                 <asp:BoundField DataField="location" HeaderText="title" SortExpression="title"><ItemStyle         Width="20" Wrap="true"/>

    i redused width to 20 then also it is not working
    LVL 5

    Accepted Solution

    This is working for me but I'm using a template column.

       <asp:TemplateField HeaderText="location" SortExpression="location" ItemStyle-Width="20px" ItemStyle-Wrap="true">  // add it here.
          <ItemStyle HorizontalAlign="Right" Width="20px" Wrap"true" />      // and add it here.
             <asp:HyperLink ID="HyperLink1" runat="server"
                NavigateUrl='<%# Eval("location", "GetLocation.aspx?location={0}").ToString()") %>'
                Text='<%# Eval("location") %>'
                Target="_blank" />
             <asp:TextBox  ID="TextBox1" runat="server" Text='<%# Eval("location") %>' />

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now