Add attribute GridBoundColumn

5 posts, 0 answers
  1. Marijn
    Marijn avatar
    2 posts
    Member since:
    Feb 2013

    Posted 20 Feb 2013 Link to this post

    Hello Telerik Users,
    I want to add an attribute to a GridBoundColumn which I create in the code. How do I achieve this?

    Kind regards,

    Marijn Ophelders
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Feb 2013 Link to this post

    Hi,

    Can you please elaborate which Attribute you want to set for the boundColumn. Please take look into the following code snippet to set BackGroundColor for Boundcolumn.

    C#:
    boundColumn1.ItemStyle.BackColor = Color.Red;
     
    OR
     
    void grid_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
            item["UniqueName"].Attributes.Add("style", "background-color:Blue");
            //OR
            item["UniqueName"].BackColor = Color.Red;
        }
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Marijn
    Marijn avatar
    2 posts
    Member since:
    Feb 2013

    Posted 22 Feb 2013 Link to this post

    Hello Shinu,
    Thnx, that helped me a lot.
    Kind regards,

    Marijn Ophelders
  5. Vasssek
    Vasssek avatar
    143 posts
    Member since:
    Aug 2010

    Posted 29 Aug in reply to Shinu Link to this post

    Hello,

    is it possible to add custom attribute to GridBoundColumn declaratively (from .ASPX) ?

    Thank you

    Vasssek

  6. Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 01 Sep Link to this post

    Hello Vasssek,

    I'm afraid this is not supported. If you want to pass a field value to the client, you can use the ClientDataKeyNames collection:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows#accessing-cells-and-values-in-client-side-code

    Regards,
    Eyup
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017