Hi,
I have bound datasource to the DataWebGrid, In which i have more than 15 columns and i want to display only 10 columns, How to do that in code behind.I need to make the visibility of column at runtime
And also i need to find the Visible Rows,
foreach(GridRecord item in WebGrid.Rows)
{
if(item.Hidden == false)
}
Item.Hidden property is not there in GridRecord.
Thanks & Regards,
Developer
Hello Tanya,
Thank you for posting in our forums!
To hide your columns, you will need to access the GridField objects. You can access the columns through the WebGrid.Columns collection. Each GridField (column) has a Hidden property that can be used to hide the column. Please see our documentation for this property below:
http://help.infragistics.com/doc/ASPNET/2014.1/CLR4.0/?page=Infragistics4.Web.v14.1~Infragistics.Web.UI.GridControls.ControlDataField~Hidden.html
Please note, if you have AutoGenerateColumns set to true, you will not be able to use the WebGrid.Columns collection. In this case, you should access the columns through a databound row. i.e. WebGrid.Rows[0].Items[0].Column.Hidden.
As for finding visible rows; rows are not able to be hidden with a property. All rows that are bound to the grid should always be visible. Are you referring to finding rows that have been filtered out or that exist on another page?
If you need any further assistance with this, please let me know.
Thanks for your reply Michael.
I need to hide 5 columns, but in my datasource i have 15 columns, When binding the data to the grid itself i need to hide the columns based on some conditions.
how can i achieve that in code behind. The column names are not known until the datasource bind to the grid.
Thanks,
Tanya