Access each column in a radgrid (Telerik) and set ItemStyle.Width (ItemDatabound)
Posted on 2013-06-25
I'm having problems with accessing a radgrids columns manually added from source code, I have loads of columns, and I don't want to repeat myself, adding the Width and change the headertext, according to my algorithm manually on each column.
Therefore I've been trying to find a way to set them automatically in the codebehind, however I am having problems accessing all the columns and settings.
The columns is as said not generated automatically.
Before When I have had the columns auto generated I have easily achieved this by using the Event ColumnCreated
protected void radGrid_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
e.Column.HeaderStyle.Width = 200;
e.Column.ItemStyle.Width = 200;
e.Column.HeaderText = "test";
e.Column.UniqueName = "test2"
Now I want to do the same but with manually added columns? (The ColumnCreated event is only triggered when the columns are auto generated, sadly =()
So something like this, by what I assume listening to the ItemDataBound event?
protected void radGrid_ItemDataBound(object sender, GridItemEventArgs e)
//Set column Width and Height and also the columns Header text and Unique name.
Appreciate any help :) Hope I made it clear enough to understand :)