RadGrid Set Column Width

7 posts, 0 answers
  1. John
    John avatar
    18 posts
    Member since:
    Oct 2010

    Posted 23 Nov 2010 Link to this post

    I am trying to set the column width in the code behind and can not figure out how to do this.  My aspx looks like:

    telerik:RadGrid ID="RadGrid1" AllowMultiRowSelection="True" runat="server" AutoGenerateColumns="False" GridLines="None" >




    MasterTableView >








    <telerik:GridBoundColumn DataField="INVOICE" UniqueName="INVOICE"











    <telerik:GridBoundColumn DataField="DATE" UniqueName="DATE" HeaderText="Date">








    <telerik:GridBoundColumn DataField="BOL" UniqueName="BOL" HeaderText="BOL">








    <telerik:GridBoundColumn DataField="PO" UniqueName="PO" HeaderText="PO">








    <telerik:GridBoundColumn DataField="POHIDE" UniqueName="POHIDE" Visible="false"



    HeaderText="PO Hide" >
















    <ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="True" >




    <Selecting AllowRowSelect="True" />









    I have tried using the RadGrid1_ColumnCreated event but no luck.  How do I change the column width at binding time?




  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 24 Nov 2010 Link to this post

    Hello John,

    You can try the code in the RadGrid PreRender event. The following code snippet will help you to achieve your scenario.

    protected void RadGrid1_PreRender(object sender, EventArgs e)
          GridColumn gridCol = RadGrid1.MasterTableView.GetColumn("LastName");
          gridCol.HeaderStyle.Width = Unit.Pixel(100);   

  3. John
    John avatar
    18 posts
    Member since:
    Oct 2010

    Posted 24 Nov 2010 Link to this post

    Thank you very much
  4. Dimo
    Dimo avatar
    8478 posts

    Posted 24 Nov 2010 Link to this post

    Hi John,

    Please be aware that ColumnCreated is fired only for autogenerated columns.

    All the best,
    the Telerik team
    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  5. Sharada
    Sharada avatar
    43 posts
    Member since:
    Mar 2009

    Posted 07 Feb 2011 Link to this post


    It worked nicely..

  6. Rajeev
    Rajeev avatar
    1 posts
    Member since:
    Jul 2011

    Posted 06 Jul 2011 Link to this post

    Post was helpful Thanks!
  7. Frank
    Frank avatar
    24 posts
    Member since:
    Nov 2010

    Posted 18 Aug 2015 in reply to Princy Link to this post

    Very late, but you want to use ((RadGrid)sender).MasterTableView.* instead. It will always apply to the correct RadGrid that way.
Back to Top