Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Grid > RadGrid Set Column Width

Not answered RadGrid Set Column Width

Feed from this thread
  • John avatar

    Posted on Nov 23, 2010 (permalink)

    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 >

     

     

     

    <Columns>

     

     

     

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

     

     

    HeaderText="Invoice">

     

     

     

    </telerik:GridBoundColumn>

     

     

     

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

     

     

     

    </telerik:GridBoundColumn>

     

     

     

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

     

     

     

    </telerik:GridBoundColumn>

     

     

     

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

     

     

     

    </telerik:GridBoundColumn>

     

     

     

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

     

     

    HeaderText="PO Hide" >

     

     

     

    </telerik:GridBoundColumn>

     

     

     

    </Columns>

     

    </

     

    MasterTableView>

     

     

     

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

     

     

     

    <Selecting AllowRowSelect="True" />

     

     

     

    </ClientSettings>

     

     

     

    </telerik:RadGrid>

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

    Thanks

    John

     

    Reply

  • Posted on Nov 24, 2010 (permalink)

    Hello John,

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

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


    Thanks,
    Princy.

    Reply

  • Say Hello to Telerik's PivotGrid for ASP.NET AJAX, Silverlight, WPF and WinForms. Now packed with OLAP support.
  • John avatar

    Posted on Nov 24, 2010 (permalink)

    Thank you very much

    Reply

  • Dimo Dimo admin's avatar

    Posted on Nov 24, 2010 (permalink)

    Hi John,

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

    All the best,
    Dimo
    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.

    Reply

  • Sharada avatar

    Posted on Feb 7, 2011 (permalink)

    Thanx.

    It worked nicely..

    Darshan

    Reply

  • Rajeev avatar

    Posted on Jul 6, 2011 (permalink)

    Post was helpful Thanks!

    Reply

  • Say Hello to Telerik's PivotGrid for ASP.NET AJAX, Silverlight, WPF and WinForms. Now packed with OLAP support.

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Grid > RadGrid Set Column Width
Related resources for "RadGrid Set Column Width"

ASP.NET Grid Features  |  Documentation  |  Demos  |  Step-by-step Tutorial  ]