Data Grid Columns
-
Can I make one of the column of my datagrid invisible?? My data grid's datasource is dataview. Me.DataGrid1.DataSource = .retrivecomm() Me.DataGrid1.DataBind() Public Function retrivecomm() As System.Data.DataView Dim con As New OleDb.OleDbConnection con.ConnectionString =Trim(ServerPath.KMSCONNECTIONSTRING) con.Open() Dim COMMDA As OleDb.OleDbCommand = New OleDb.OleDbCommand("select * from TABLE", con) Dim COMMDR As OleDb.OleDbDataReader COMMDR = COMMDA.ExecuteReader(CommandBehavior.CloseConnection) Dim dt As New DataTable Dim dr As DataRow Dim i As Integer dt.Columns.Add(New DataColumn("Code", GetType(String))) dt.Columns.Add(New DataColumn("Description", GetType(String))) dt.Columns.Add(New DataColumn("Color", GetType(Double))) Do While COMMDR.Read() dr = dt.NewRow() dr(0) = COMMDR.GetString(0) dr(1) = COMMDR.GetString(1) dr(2) = COMMDR.GetString(2) dt.Rows.Add(dr) Loop Dim dv As New DataView(dt) retrivecomm = dv COMMDR.Close() COMMDA.Dispose() con.Dispose() End Function I want hide the third column i.e. Color column Chintan
-
Can I make one of the column of my datagrid invisible?? My data grid's datasource is dataview. Me.DataGrid1.DataSource = .retrivecomm() Me.DataGrid1.DataBind() Public Function retrivecomm() As System.Data.DataView Dim con As New OleDb.OleDbConnection con.ConnectionString =Trim(ServerPath.KMSCONNECTIONSTRING) con.Open() Dim COMMDA As OleDb.OleDbCommand = New OleDb.OleDbCommand("select * from TABLE", con) Dim COMMDR As OleDb.OleDbDataReader COMMDR = COMMDA.ExecuteReader(CommandBehavior.CloseConnection) Dim dt As New DataTable Dim dr As DataRow Dim i As Integer dt.Columns.Add(New DataColumn("Code", GetType(String))) dt.Columns.Add(New DataColumn("Description", GetType(String))) dt.Columns.Add(New DataColumn("Color", GetType(Double))) Do While COMMDR.Read() dr = dt.NewRow() dr(0) = COMMDR.GetString(0) dr(1) = COMMDR.GetString(1) dr(2) = COMMDR.GetString(2) dt.Rows.Add(dr) Loop Dim dv As New DataView(dt) retrivecomm = dv COMMDR.Close() COMMDA.Dispose() con.Dispose() End Function I want hide the third column i.e. Color column Chintan
Hi Chintan, If you're specifying each column individually in the [Columns] section of your [asp:Datagrid], then you can hide them with this: DataGrid1.Columns(2).Visible = False For AutoGeneratedColumns, it's a bit more complicated, but I have a sample available here. Hope that helps, Marcie CP Blog[^]