Set Column Width of RadGrid Items

5 posts, 1 answers
  1. Robert
    Robert  avatar
    68 posts
    Member since:
    Feb 2009

    Posted 07 Nov 2012 Link to this post

    I am writing to ask how best column width can be set RadGrid Columns - either in C#, or .aspx;

    Thanks in advance for any insight - best regards;
    <telerik:RadGrid ID="RadGrid2" runat="server" AllowPaging="True" OnNeedDataSource="RadGrid2_NeedDataSource" AllowSorting="true" AllowFilteringByColumn="true" >
               <ClientSettings EnableRowHoverStyle="true">
                   <Selecting AllowRowSelect="true" />
               <MasterTableView AllowMultiColumnSorting="True">

    public DataTable GetDataTable(string query)
            String ConnString = "";
            //ConnString = ConfigurationManager.ConnectionStrings["CapacityManagement"].ConnectionString;
            ConnString = ConfigurationManager.ConnectionStrings[2].ConnectionString;
            SqlConnection conn = new SqlConnection(ConnString);
            SqlDataAdapter adapter = new SqlDataAdapter();
            adapter.SelectCommand = new SqlCommand(query, conn);
            DataTable myDataTable = new DataTable();
            return myDataTable;

    protected void RadGrid2_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
           (source as RadGrid).DataSource = GetDataTable("SELECT Date, Location, EquipmentType, InstalledPorts, UsedPorts, ReservedPorts, AvailablePorts, Utilization, ThreeMonthUtil, TwelveMonthUtil From tblSAMPortsLocationSummary");

  2. Answer
    Jayesh Goyani
    Jayesh Goyani avatar
    2733 posts
    Member since:
    May 2010

    Posted 07 Nov 2012 Link to this post


    Method : 1 -  by using below method if you want to change your column width in future then you can do it easily. I think it dose not matter you can assign in .aspx or .aspx.cs

    but if we want to change this width in future then we can easily manage in .aspx with compare to .aspx.cs.

    Add below class in your .css file.
              width: 100px;

    assign this class in to below column.
    <telerik:GridBoundColumn DataField="Name" UniqueName="Name" HeaderText="Name">
                           <HeaderStyle CssClass="myclass" />
                           <ItemStyle CssClass="myclass" />

    Jayesh Goyani
  3. Mohammad
    Mohammad avatar
    1 posts
    Member since:
    Sep 2013

    Posted 10 Oct 2013 Link to this post

    Not working... :(
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 10 Oct 2013 Link to this post

    Hi Mohammad,

    Please try setting the TableLayout of the radgrid to Fixed and check if it helps.

    <MasterTableView TableLayout="Fixed" . . >

  5. lv
    lv avatar
    1 posts
    Member since:
    Jul 2015

    Posted 09 Oct 2015 in reply to Princy Link to this post

    Thank you! It solved my problem.
Back to Top