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

Add attribute GridBoundColumn

4 Answers 570 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Marijn
Top achievements
Rank 1
Marijn asked on 20 Feb 2013, 10:04 AM
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

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Feb 2013, 11:15 AM
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.
0
Marijn
Top achievements
Rank 1
answered on 22 Feb 2013, 07:27 AM
Hello Shinu,
Thnx, that helped me a lot.
Kind regards,

Marijn Ophelders
0
Vasssek
Top achievements
Rank 1
answered on 29 Aug 2016, 04:03 PM

Hello,

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

Thank you

Vasssek

0
Eyup
Telerik team
answered on 01 Sep 2016, 10:39 AM
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.
Tags
Grid
Asked by
Marijn
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Marijn
Top achievements
Rank 1
Vasssek
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or