radgrid removing column on runtime

10 posts, 0 answers
  1. DragonBall
    DragonBall avatar
    53 posts
    Member since:
    Jul 2008

    Posted 08 Dec 2008 Link to this post

    how do i remove the column(s) in the radgrid on runtime.
    can anybody help me with this.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 09 Dec 2008 Link to this post

    Hi Manuel,

    I would suggest you to hide the desired Grid column using the Visible or Display property.

    CS:
     RadGrid1.MasterTableView.GetColumn("ProductName").Visible = false

    or
    RadGrid1.MasterTableView.GetColumn("ProductName").Display = false

    Shinu
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Imthiyas
    Imthiyas  avatar
    9 posts
    Member since:
    Dec 2008

    Posted 23 Dec 2008 Link to this post

    Hi,

    I have set the data source for the Rad Grid. after databind() when i check the column count it is still 0. I have used AutoGenerateColumns = "False" since iam not creating columns declaratively.

    I need to delete a column where i can do that.

    Thanks
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 24 Dec 2008 Link to this post

    Hi Imthiyas,

    In the above post you have mentioned that you are not creating columns declaratively and AutoGenerateColumns property is set to false so I hope you are adding columns dynamically. From my knowledge it is not possible to delete a Grid column which is already added in the Grid's Column collection. One suggestion will be to set its Visibile/Display property to false as shown above.

    Princy.




  6. Sagar
    Sagar avatar
    3 posts
    Member since:
    Jun 2013

    Posted 02 Jul 2013 Link to this post

    Shinu its Working !!!thanks
  7. Chandra Mohan
    Chandra Mohan avatar
    1 posts
    Member since:
    Dec 2013

    Posted 17 Sep 2014 in reply to DragonBall Link to this post

    Hi DragonBall

    you can hide/remove any column with  follwing code dynamically with its index.....

    RadGrid.Columns.Remove(RadGrid.Columns[9]);

  8. wael
    wael avatar
    3 posts
    Member since:
    Apr 2014

    Posted 06 Mar 2015 in reply to Chandra Mohan Link to this post

    how can i get column index by name 
  9. Ibraheem
    Ibraheem avatar
    3 posts
    Member since:
    Oct 2011

    Posted 06 Apr 2015 Link to this post

    @Shinu You said

    RadGrid1.MasterTableView.GetColumn("ProductName").Visible = false;

     Very good. But when we use this code?? In what event???????

    I have "autogeneratecolumns=true" and I have tried OnDataBound but the ID column was not found.

  10. Ibraheem
    Ibraheem avatar
    3 posts
    Member since:
    Oct 2011

    Posted 06 Apr 2015 in reply to wael Link to this post

    protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    RadGrid1.Columns.FindByUniqueName("Edit").OrderIndex = 50;
                    RadGrid1.Rebind();
                }
            }
  11. Ibraheem
    Ibraheem avatar
    3 posts
    Member since:
    Oct 2011

    Posted 06 Apr 2015 in reply to Ibraheem Link to this post

    Yes, I found it (Alhamulellah)

    protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
    {
        if (IdColumnHidden && e.Column.UniqueName.ToLower() == "id")
            e.Column.Visible = false;
    }

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017