Desperate for help - setting row height and overflow

2 posts, 0 answers
  1. Todd Davis
    Todd Davis avatar
    36 posts
    Member since:
    Aug 2009

    Posted 26 Sep 2009 Link to this post

    I have a radgrid on my web page with several columns of data. One of those columns contains a fairly large amount of text data in every row, so the row heights are pretty huge. I tried setting  ItemStyle-Height="20px". but that did absolutely nothing to resolve the problem. Clearly the height is adjusting to accommodate all the text in the cell, but that's not what I want in this case. I want the text overflow to be hidden.

    One special note - This grid (and the text in particular) is going to be exported to XLS, so I don't want to shorten it (i.e. add some function to show only (x) characters). It needs to be available, just offscreen.

    I'm on a tight timeline, so please help me!


  2. Dimo
    Dimo avatar
    8407 posts

    Posted 28 Sep 2009 Link to this post

    Hello Todd,

    Table cells in general do not support the behavior that you are after. You need to use a template column or insert a <div> tag around the text content. Here is an example showing the latter:

    <%@ Page Language="C#" %> 
    <%@ Import Namespace="System.Data" %> 
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    <script runat="server"
        protected void RadGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) 
            string s = "This is a long string, which will be used inside a special RadGrid cell."
            string MyLongString = String.Format("{0} {0} {0} {0} {0} {0} {0} {0} {0} {0} {0} {0} {0} {0} {0} {0} {0}", s); 
            DataTable dt = new DataTable(); 
            DataRow dr; 
            for (int i = 1; i <= 5; i++) 
                dr = dt.NewRow(); 
                dr["Column1"] = MyLongString; 
            (sender as RadGrid).DataSource = dt
        protected void Button1_Click(object sender, EventArgs e) 
    <html xmlns="" > 
    <head runat="server"
    <meta http-equiv="content-type" content="text/html;charset=utf-8" /> 
    <title>RadControls for ASP.NET AJAX</title> 
    <style type="text/css" media="screen"
    <form id="form1" runat="server"
    <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
                <telerik:GridBoundColumn DataField="Column1" HeaderText="Large Text Column" DataFormatString="<div class='mydiv'>{0}</div>" /> 
    <asp:Button ID="Button1" runat="server" Text="Export to XLS" OnClick="Button1_Click" /> 

    Best wishes,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top