How to removed RadGrid first column with code.

7 posts, 0 answers
  1. Netra
    Netra avatar
    4 posts
    Member since:
    Aug 2012

    Posted 02 Aug 2012 Link to this post

      Hello All,

    I am using RadGrid and binding data dynamically in code behind file.

     Code Behind:
    RadGrid grSampleWorkSheet = new RadGrid();
                                    grSampleWorkSheet.ID = WSheet.Name + "-" + m_LoopCount.ToString();
                                    //grSampleWorkSheet.Columns.Remove(0);// = false;
                                    grSampleWorkSheet.ShowGroupPanel = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["ShowGroupPanel"]);
                                    grSampleWorkSheet.AllowPaging = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["AllowPaging"]);
                                    grSampleWorkSheet.ShowFooter = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["ShowFooter"]);
                                    grSampleWorkSheet.ShowStatusBar = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["ShowStatusBar"]);
                                    grSampleWorkSheet.Skin = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["TelerikSkin"]);
                                    grSampleWorkSheet.MasterTableView.PagerStyle.Mode = GridPagerMode.NumericPages;
     
     
                                    WorkSheetID = WSheet.ID;
                                    strWorkSheetID = objWorkSheet[0].Name;
                                    //if (ddlWorkSheets.SelectedValue == strWorkSheetID)
                                    //{
                                    dtworksheet = GenerateNormalizedRateSheet.GenerateDomesticSampleData(objRateSheet, WorkSheetID, out ErrorCode);
                                    if (string.IsNullOrEmpty(ErrorCode))
                                    {
                                        if (dtworksheet != null && dtworksheet.Rows.Count > 0)
                                        {
                                            grSampleWorkSheet.DataSource = dtworksheet;
                                            grSampleWorkSheet.Columns.Remove(0);
                                            grSampleWorkSheet.DataBind();
                                            grSampleWorkSheet.MasterTableView.DataSource = dtworksheet;
                                            grSampleWorkSheet.MasterTableView.Columns.Remove(0);
                                            grSampleWorkSheet.MasterTableView.DataBind();
                                            Label lblDomesticTitle = new Label();
                                            lblDomesticTitle.ID = "lbl-" + WorkSheetID;
                                            lblDomesticTitle.Text = "<h5>" + strWorkSheetID + "</h5>";
                                            PhSampleData.Controls.Add(lblDomesticTitle);
                                            PhSampleData.Controls.Add(grSampleWorkSheet);
                                            btnNextStep.Enabled = true;
      }
    }

    I have also attached image file of result.

    Thanks in Advanced...
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Aug 2012 Link to this post

    Hello,

    Try hiding the column as shown below.
    C#:
    void RadGrid1_PreRender(object sender, EventArgs e)
    {
        RadGrid1.MasterTableView.GetColumn("UniqueName").Visible = false;
    }

    Thanks,
    Shinu.
  3. Netra
    Netra avatar
    4 posts
    Member since:
    Aug 2012

    Posted 02 Aug 2012 Link to this post

    Hi Shinu,
    Thanks for reply.
    If you can see the attachment? first column don't have any Column name.
  4. Jayesh Goyani
    Jayesh Goyani avatar
    2733 posts
    Member since:
    May 2010

    Posted 02 Aug 2012 Link to this post

    Hello,

    RadGrid1.MasterTableView.Columns[0].Visible = false;


    Thanks,
    Jayesh Goyani
  5. Netra
    Netra avatar
    4 posts
    Member since:
    Aug 2012

    Posted 02 Aug 2012 Link to this post

    Hello Jayesh,

    I used your code
            grSampleWorkSheet.MasterTableView.Columns[0].Visible = false;
    I get an ERROR:Failed accessing GridColumn by index. Please verify that you have specified the structure of RadGrid correctly.
  6. Netra
    Netra avatar
    4 posts
    Member since:
    Aug 2012

    Posted 02 Aug 2012 Link to this post

    Hello All,

    Thanks those who had replied.
    I resolved my issue using following code:
    grSampleWorkSheet.MasterTableView.RowIndicatorColumn.Visible = false;
    grSampleWorkSheet.MasterTableView.ExpandCollapseColumn.Visible = false;
    Thanks....
  7. Prasanth
    Prasanth avatar
    2 posts
    Member since:
    Sep 2016

    Posted 19 Feb 2018 Link to this post

    Hello All, 

    Set the attribute AllowRowResize to False. 

    <ClientSettings ........>
                <Resizing AllowRowResize="False"............. ></Resizing>

    </ClientSettings>

     

Back to Top