Solved

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

Posted on 2013-06-25
2
2,682 Views
Last Modified: 2013-06-25
Hello!

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 :)
0
Comment
Question by:clooak
  • 2
2 Comments
 

Accepted Solution

by:
clooak earned 0 total points
Comment Utility
Solved it myself using the PreRender event connected to the gridview

Eg.

protected void RadGrid1_PreRender(object sender, EventArgs e)          
{
        foreach (GridColumn col in RadGrid1.Columns)
        {
          col.HeaderStyle.Width = 600;
        }
}
0
 

Author Closing Comment

by:clooak
Comment Utility
Solved it myself (see reply marked as answer)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now