How to suppress a column in datagrid? (vb.net 1.1)
-
-
I am using vb.net 1.1 for desktop application. While displaying contents of a datatable / dataview in a datagrid, I wish to suppress some columns (foreign keys, few admin fields) which user is not concerned with. how do I do it?
thanks, Madhav
-
I am using vb.net 1.1 for desktop application. While displaying contents of a datatable / dataview in a datagrid, I wish to suppress some columns (foreign keys, few admin fields) which user is not concerned with. how do I do it?
thanks, Madhav
infotools wrote:
While displaying contents of a datatable / dataview in a datagrid, I wish to suppress some columns (foreign keys, few admin fields) which user is not concerned with.
You could build a query and only select the columns that you want to display using that query, before you bind the datatable to the grid, i.e:
SELECT column1, column2, ... FROM [tableName] WHERE ...
Pete Soheil DigiOz Multimedia http://www.digioz.com
-
I am using vb.net 1.1 for desktop application. While displaying contents of a datatable / dataview in a datagrid, I wish to suppress some columns (foreign keys, few admin fields) which user is not concerned with. how do I do it?
thanks, Madhav
When the User Logs on, make sure his UserGroup is stored in a session variable i.e. Session("AccessGroup") = row("vchAccessGroupName") Then in the OnItemDatabound event for the datagrid: If Session("AccessGroup") <> "Admin" Then e.Item.Cells(x).Visible = False //////x being the index of the column in the html End If That's all really. Hope this helps.
-
If you are using visual basic 2003 then you can use the following statement I think the styanx for hidding a column is like this. datatable.columns(0).columnmapping = Hidden
Hello, Thanks for indicating the way. Actual code is tblMaster.Columns("Id").ColumnMapping = MappingType.Hidden tblMaster.Columns("IsBillable").ColumnMapping = MappingType.Hidden where "tblMaster" is datatable, it does work and seems to be correct way of doing this. Now I am trying to see how the hidden columns will be updated when foreign key values change due to change in name/description of foreign key or when a new record is added. I will post the concerned code when I check it thoroughly. thanks once again.
thanks, Madhav