Solved

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

Posted on 2013-06-25
2
2,752 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using C# How can I sample the current mouse position in a window 16 63
VB.net/VSTO Excel Add-in 2 39
c#, datatable, aspx 4 53
SSIS Column mapping 5 42
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

752 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