This is a migrated thread and some comments may be shown as answers.

Limiting amount of data displayed in a column

2 Answers 23 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kathy
Top achievements
Rank 1
Kathy asked on 25 Oct 2010, 12:10 PM
One of the fields that I get back from the database has a max length of 200 characters.  I want to only show about 80 characters when in grid view, with an elipsis at the end of the data so that the user knows there is more text.  All the text would be shown when in edit mode.  What would be the best way to accomplish this?  Thanks.

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 25 Oct 2010, 12:14 PM
Hi Kathy,


The following code will help you in adding ellipsis to grid cell and show the complete text as tool-tip.

Code:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;           
        if (item["Description"].Text.Length > 80)
        {
            item["Description"].ToolTip = item["Description"].Text.ToString(); // Set the Tooltip
            item["Description"].Text = (item["Description"].Text).Substring(0, 5) + "...";
        }
    }
}



-Shinu.
0
Kathy
Top achievements
Rank 1
answered on 25 Oct 2010, 12:27 PM
Thanks for the really fast response.  It worked like a charm.
Tags
Grid
Asked by
Kathy
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Kathy
Top achievements
Rank 1
Share this question
or