|
-
Oct 3rd, 2005, 02:16 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] how to hide unbounded columns in a datagrid
guys how can i hide unbounded columns in a datagrid? TIA
If a post has helped you then Please Rate it!
-
Oct 3rd, 2005, 03:22 AM
#2
Lively Member
Re: how to hide unbounded columns in a datagrid
Private Sub ingrid_ItemDataBound(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles ingrid.ItemDataBound
e.Item.Cells(7).Visible = False
End
or use this
DataGrid1.Columns(1).Visible = Not (DataGrid1.Columns(1).Visible)
I hope one of them will work well.
Happy Programming
-
Oct 3rd, 2005, 09:03 PM
#3
Thread Starter
Fanatic Member
Re: how to hide unbounded columns in a datagrid
thanks for replying.
 Originally Posted by AjayKumar
Private Sub ingrid_ItemDataBound(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles ingrid.ItemDataBound
e.Item.Cells(7).Visible = False
End
[ this code will hide just the header item selected and not the entire column will result in unmatched header and row. ]
or use this
DataGrid1.Columns(1).Visible = Not (DataGrid1.Columns(1).Visible)
[ this code works only with bounded columns and will return index error if used. ]
I hope one of them will work well.
Happy Programming
Last edited by VBKNIGHT; Oct 3rd, 2005 at 09:12 PM.
If a post has helped you then Please Rate it!
-
Oct 3rd, 2005, 11:33 PM
#4
Lively Member
Re: how to hide unbounded columns in a datagrid
Use visibility options in both of events
Private Sub ingrid_ItemDataBound(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles ingrid.ItemDataBound
e.Item.Cells(7).Visible = False
Select Case e.Item.ItemType
Case ListItemType.Header
e.Item.Cells(7).Visible = False
Case ListItemType.Item
e.Item.Cells(7).Visible = False
Case ListItemType.AlternatingItem
e.Item.Cells(7).Visible = False
End
and in itemcreated event also
Private Sub ingrid_ItemCreated(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles ingrid.ItemCreated
Select Case e.Item.ItemType
Case ListItemType.Header
e.Item.Cells(7).Visible = False
Case ListItemType.Item
e.Item.Cells(7).Visible = False
Case ListItemType.AlternatingItem
e.Item.Cells(7).Visible = False
End Select
End Sub
-
Oct 4th, 2005, 03:51 AM
#5
Thread Starter
Fanatic Member
Re: how to hide unbounded columns in a datagrid
thanks! this is what i need.
If a post has helped you then Please Rate it!
-
Oct 4th, 2005, 09:46 AM
#6
Re: how to hide unbounded columns in a datagrid
VB Code:
Select Case e.Item.ItemType
Case ListItemType.Header
e.Item.Cells(7).Visible = False
Case ListItemType.Item
e.Item.Cells(7).Visible = False
Case ListItemType.AlternatingItem
e.Item.Cells(7).Visible = False
End Select
That can be replaced with:
VB Code:
e.Item.Cells(7).Visible = False
Alternatively, if you only want to show the bound columns, then do:
VB Code:
MyDataGrid.AutoGenerateColumns = False
Then regardless of how many columns there are in the datasource, only the bound columns you set up get shown.
Woka
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|