wrap text in datagrid cell

Discussion in 'ASP .Net' started by ireallyneedtoknow2007@yahoo.com, Nov 12, 2007.

  1. Guest

    here is a cleaner version of a question I posted yesterday. I have
    tried many versions of the code below but cannot get the column to
    wrap. I am using asp.net 2.0 visual studio 2005. ultimately I will
    be adding template columns as well, but really need this column to
    wrap. thanks for your help

    <asp:datagrid id="myDataGrid" style="Z-INDEX: 100; LEFT: 20px;
    POSITION: absolute; TOP: 260px" runat=server
    AllowSorting="True" Font-Size="X-Small" Font-Names="Verdana"
    ForeColor="Black"
    GridLines="None" CellPadding="2" BackColor="LightGoldenrodYellow"
    BorderWidth="1px"
    BorderColor="Tan" Width="100px" Height="304px"
    OnPreRender="myDataGrid_PreRender" AutoGenerateColumns="False"
    BorderStyle="Solid" CellSpacing="2">

    <Columns>
    <asp:BoundColumn DataField="contact_email" ReadOnly="True"
    HeaderText="Emailx">
    <ItemStyle Wrap="True" ></ItemStyle>
    <HeaderStyle Width="5px" Wrap=true/>
    </asp:BoundColumn>
    </Columns>

    </asp:datagrid>



    public void myDataGrid_PreRender(object sender, System.EventArgs e)
    {
    myDataGrid.Columns[0].ItemStyle.Width = 30;
    myDataGrid.Columns[0].ItemStyle.Wrap = true;
    }
    , Nov 12, 2007
    #1
    1. Advertising

  2. Take a look at "word-break:break-word" and similar CSS style behaviors.
    -- Peter
    http://www.eggheadcafe.com
    unBlog: http://petesbloggerama.blogspot.com
    BlogMetaFinder: http://www.blogmetafinder.com



    "" wrote:

    > here is a cleaner version of a question I posted yesterday. I have
    > tried many versions of the code below but cannot get the column to
    > wrap. I am using asp.net 2.0 visual studio 2005. ultimately I will
    > be adding template columns as well, but really need this column to
    > wrap. thanks for your help
    >
    > <asp:datagrid id="myDataGrid" style="Z-INDEX: 100; LEFT: 20px;
    > POSITION: absolute; TOP: 260px" runat=server
    > AllowSorting="True" Font-Size="X-Small" Font-Names="Verdana"
    > ForeColor="Black"
    > GridLines="None" CellPadding="2" BackColor="LightGoldenrodYellow"
    > BorderWidth="1px"
    > BorderColor="Tan" Width="100px" Height="304px"
    > OnPreRender="myDataGrid_PreRender" AutoGenerateColumns="False"
    > BorderStyle="Solid" CellSpacing="2">
    >
    > <Columns>
    > <asp:BoundColumn DataField="contact_email" ReadOnly="True"
    > HeaderText="Emailx">
    > <ItemStyle Wrap="True" ></ItemStyle>
    > <HeaderStyle Width="5px" Wrap=true/>
    > </asp:BoundColumn>
    > </Columns>
    >
    > </asp:datagrid>
    >
    >
    >
    > public void myDataGrid_PreRender(object sender, System.EventArgs e)
    > {
    > myDataGrid.Columns[0].ItemStyle.Width = 30;
    > myDataGrid.Columns[0].ItemStyle.Wrap = true;
    > }
    >
    >
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Nov 12, 2007
    #2
    1. Advertising

  3. Guest

    thanks, no doubt I did something wrong but I could not get <style> to
    work. however replacing a comma with a comma<br> in my sql did give
    me what I needed.

    <style>
    .fixed_cell
    {
    word-wrap:break-word;
    width:25px;
    }
    </style>

    <asp:BoundColumn DataField="contact_email" ReadOnly="True"
    HeaderText="Email" ItemStyle-CssClass="fixed_cell" >


    select replace(contact_email,',',',<br>') as contact_email from mytable
    , Nov 12, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Aaron Fude

    To wrap or not to wrap?

    Aaron Fude, May 8, 2008, in forum: Java
    Replies:
    12
    Views:
    686
    Chronic Philharmonic
    May 10, 2008
  2. Paul

    wrap text within cell-not working with data grid

    Paul, Nov 24, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    123
  3. Leshak Leshak

    How to wrap text in an Excel cell?

    Leshak Leshak, Jul 2, 2008, in forum: Ruby
    Replies:
    4
    Views:
    361
    Alex ...
    Jul 4, 2008
  4. Art Werschulz

    Text::Wrap::wrap difference

    Art Werschulz, Sep 22, 2003, in forum: Perl Misc
    Replies:
    0
    Views:
    221
    Art Werschulz
    Sep 22, 2003
  5. Art Werschulz

    Text::Wrap::wrap difference

    Art Werschulz, Sep 24, 2003, in forum: Perl Misc
    Replies:
    1
    Views:
    233
    Anno Siegel
    Sep 25, 2003
Loading...

Share This Page