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

[Solved] How to Hide Dynamically added Columns

2 Answers 811 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jidesh Guptha
Top achievements
Rank 1
Jidesh Guptha asked on 27 Jul 2009, 02:50 PM
Hi,

I have added a RAD Grid in my page. I am executing a query and preparing a data table and assigning that to the rad grid, The data is populating in the grid perfectly. I do not want to show few columns to the user but i actually want to use those values.

for hiding the first column i used the following code

RadGrid1.Columns[1].Display =

falseBut showed me an error.
Then i tried with the following code

 

RadGrid1.MasterTableView.RenderColumns[1].Display =

false;

 

 

This did not show me an error but did not hide the column

Guide me how to go about this.

Jidesh

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 28 Jul 2009, 04:46 AM
Hi Jidesh,

Try hiding the Grid column using the column's UniqueName property instead of column Index. The UniqueName for the column will be same as the DataField for auto-generated columns.

CS:
 
 protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        RadGrid1.MasterTableView.GetColumn("ProductName").Display = false
 
 
    }


Regards
Shinu.
0
Jidesh Guptha
Top achievements
Rank 1
answered on 04 Aug 2009, 05:23 AM
Hi Shinu,

I Have a problem in Dynamically Added Columns to rad grid.
i am creating a usercontrol with Grid.
1. Am using IList as the data source for the Grid
2. I am Adding the columns to the grid dynamically , setting the Data field, unique name and header text and adding it to the mastertable view of the grid.
3. In the page load event and the Need Datasource Event of the grid am creating the columns(if the column already exist then removing the column and recreating it)  and loading the data to the grid
4. i have set the enable postback on row click event
5. Also have a Context menu for all the row.

I have two problem s
1. On clicking the rows the header text is disappearing.
2. On filtering am not getting the filtered record.
        I Thought that removing the column and recreating would be the issue. so tried not to cleare the existing column. Now i get the IList object name in the grid as the row value. Hope the data field is not been set.

Pls guide me how to solve this issue.

Tags
Grid
Asked by
Jidesh Guptha
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jidesh Guptha
Top achievements
Rank 1
Share this question
or