Hi,
I have created a webgrid and bounced it to a dataTable which is related to another dataTable (in order to have drill down).
I defined hidden columns in both dataTables, but still these columns are presented in the webGrid.
below is part of the code:
// Set the WebGrid's view type to Hierarchical
//Hide the irrelevant columns
resDataSet.Tables[1].Columns["parent_eventID"].ColumnMapping = MappingType.Hidden;
resDataSet.Tables[1].Columns["cascadeID"].ColumnMapping = MappingType.Hidden;
this.wGrid_RRCalc.DataSource = resDataSet.Tables[2];
this.wGrid_RRCalc.DataBind();
Please advice
Thanks
Maya
I would set the .Hidden property of the columns in the grid.
MyGrid.Bands(0).Columns(0).Hidden = True
(And, of course, hard-coded constants are not the best way to specify which band or column.)
First of all - Thanks.
Now I have few problems:
So, as I understand - from the webGrid point of view there is no meaning to the hidden columns of it's bounded dataTable ???
mbakshi said:1. I'm using drill down for that webGrid and I wanna hide columns both on the parent and the child tables.
Bands[0] is the parent table, Bands[1] is the child table.
mbakshi said:2. The table structure is flexible and the webGrid is bounded to a dataTable returned from a stored procedure. that dataTable can have different columns from time to time and for that reason I can't use hard coded constants.
(One of many reasons to avoid hard-coded constants)
mbakshi said:3. wGrid_RRCalc.Bands[0].Columns.Count is 0 for some reason.
AFAIK, if you're using AutoGenerateColumns, it will be 0 until the grid is bound. Try setting .Hidden properties in the grid's .DataBound event handler.
Another approach, instead of using AutoGenerateColumns, would be to define your bands and columns dynamically, in the grid's .InitializeLayout handler.
mbakshi said:So, as I understand - from the webGrid point of view there is no meaning to the hidden columns of it's bounded dataTable ???
I don't know. I've never hidden columns within a DataTable.