Solved

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

Posted on 2013-06-25
2
2,709 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
ID: 39274319
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
ID: 39274321
Solved it myself (see reply marked as answer)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

929 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

16 Experts available now in Live!

Get 1:1 Help Now