String format issue in RadGrid

2 posts, 0 answers
  1. Shrujan
    Shrujan avatar
    1 posts
    Member since:
    Jul 2015

    Posted 08 Jul 2015 Link to this post

    Hi Team,

     While i'm trying to bind the string data to the Rad Grid it is not binding exact value which i have pulled from Data Base.

    For Example i'm pulling the Data    : -   "A     BC         E F G"      and binding the same data to the Rad Grid, the problem here is the rad grid column is trimming out all the spaces and displaying like     :-  "A BC EFG"    

    Here i need to bind the exact data which i'm pulling from Database.

    Could you please help me out from this issue.

     

    Thanks in Advance

    A.Shrujan

     

     

     

  2. Kostadin
    Admin
    Kostadin avatar
    1733 posts

    Posted 13 Jul 2015 Link to this post

    Hello Shrujan,

    The white spaces are removed by the browser and in order to keep them you have to replace the white spaces with  . Please check out the following code snippet which demonstrates how to achieve that.
    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = e.Item as GridDataItem;
            item["Column1"].Text = item["Column1"].Text.Replace(" ", " ");
        }
    }


    Regards,
    Kostadin
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top