This is a migrated thread and some comments may be shown as answers.

radgrid removing column on runtime

9 Answers 1338 Views
Grid
This is a migrated thread and some comments may be shown as answers.
DragonBall
Top achievements
Rank 1
DragonBall asked on 09 Dec 2008, 04:15 AM
how do i remove the column(s) in the radgrid on runtime.
can anybody help me with this.

9 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 09 Dec 2008, 07:48 AM
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
0
Imthiyas
Top achievements
Rank 1
answered on 23 Dec 2008, 03:54 PM
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
0
Princy
Top achievements
Rank 2
answered on 24 Dec 2008, 06:24 AM
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.




0
Sagar
Top achievements
Rank 1
answered on 02 Jul 2013, 06:39 AM
Shinu its Working !!!thanks
0
Chandra Mohan
Top achievements
Rank 1
answered on 17 Sep 2014, 10:27 AM
Hi DragonBall

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

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

0
wael
Top achievements
Rank 1
answered on 06 Mar 2015, 03:15 PM
how can i get column index by name 
0
Ibraheem
Top achievements
Rank 1
answered on 06 Apr 2015, 07:19 AM

@Shinu You said [quote]RadGrid1.MasterTableView.GetColumn("ProductName").Visible = false;[/quote]

 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.

0
Ibraheem
Top achievements
Rank 1
answered on 06 Apr 2015, 07:21 AM
protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                RadGrid1.Columns.FindByUniqueName("Edit").OrderIndex = 50;
                RadGrid1.Rebind();
            }
        }
0
Ibraheem
Top achievements
Rank 1
answered on 06 Apr 2015, 07:33 AM

Yes, I found it (Alhamulellah)

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

Tags
Grid
Asked by
DragonBall
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Imthiyas
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Sagar
Top achievements
Rank 1
Chandra Mohan
Top achievements
Rank 1
wael
Top achievements
Rank 1
Ibraheem
Top achievements
Rank 1
Share this question
or