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

radgrid "AutoGenerateColumns=false" issue

1 Answer 138 Views
Grid
This is a migrated thread and some comments may be shown as answers.
nelson
Top achievements
Rank 1
nelson asked on 21 Jul 2010, 01:18 PM
Hi
I am dynamically generating the RadGrid. Everything is dynamic.
I have kept the autogenerateColumns property false. And i have dounded only one column. But when my page renders it shows all the columns in the database.But actually i want only one column. I have pasted the code below.

TableRow

 

objTR = new TableRow();

 

ControlToAdd.Controls.Add(objTR);

 

TableCell objTC;

 

 

DataTable forGridDT = new DataTable();

 

forGridDT =

Common.getDataTableByList(listQuery, ListName,ListColumns);

 

 

 

 

//I am getting the data from the share point. Which is returning me the all columns with values.

RadGrid
RadGrid1 = new RadGrid();

 

RadGrid1.ID =  objRadGrid

RadGrid1.AllowPaging = true;

 

RadGrid1.AutoGenerateColumns =

false;

 

RadGrid1.DataSource = forGridDT;

RadGrid1.DataBind();

 

 

GridBoundColumn boundColumn = new GridBoundColumn();

 

boundColumn.DataField =

"Category";

 

 

//boundColumn.DataType =Type.st;

 

boundColumn.HeaderText =

"Category";

 

boundColumn.UniqueName =

"Category";

 

RadGrid1.MasterTableView.Columns.Clear();

RadGrid1.MasterTableView.Columns.Add(boundColumn);

objTC =

new TableCell();

 

objTC.Width =

new Unit("100%");

 

objTC.Controls.Add(RadGrid1);

objTR.Controls.Add(objTC);

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 22 Jul 2010, 12:54 PM
Hello,

Try setting 'RadGrid1.MasterTableView.AutoGenerateColumns = false;'  and see whether it helps.

Also go through the following documentation which describes how to creating RadGrid entirely on code behind.
Programmatic creation

-Shinu.
Tags
Grid
Asked by
nelson
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or