• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2844
  • Last Modified:

Access each column in a radgrid (Telerik) and set ItemStyle.Width (ItemDatabound)


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.

Any idea?

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 :)
  • 2
1 Solution
clooakAuthor Commented:
Solved it myself using the PreRender event connected to the gridview


protected void RadGrid1_PreRender(object sender, EventArgs e)          
        foreach (GridColumn col in RadGrid1.Columns)
          col.HeaderStyle.Width = 600;
clooakAuthor Commented:
Solved it myself (see reply marked as answer)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now