I am binding my Data Grid at runtime. I want to know how to hide some columns at rumtime according to some conditions.
Here is my sample code:
Thats
void .ReportDetailsDataSource(List<ManagementReport> data)
{
ManagementDetailsUltraWebGrid.DataSource = data;
ManagementDetailsUltraWebGrid.DataBind();
}
Here I am binding my list of objects to grid.
Now I want to hide some columns. I tried to use Display layout property and able to hide by index of column.
ManagementDetailsUltraWebGrid.DisplayLayout.Bands[0].
Columns[1].Hidden = isHidden;
But I know the columns name instead of columns index.
Is there any way to hide columns by there Names also.
Thanks
Yepe Its working now. Thank you very much. I really appreciate you help.
Could you please see following post and see if you can help me.
Thanks again
Sorry for the bad answer, I didn't read correctly.
Have you tried something like this?
ManagementDetailsUltraWebGrid.Columns.FromKey("NAME").Hidden = isHidden;
Yes I know I can use that. But I dont know the index number of columns. I know column Names instead of column index.
You can use ManagementDetailsUltraWebGrid.Columns[1].Hidden = isHidden;