Hide datagrid column
- From: Das <Das@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 11 Apr 2005 06:30:01 -0700
Hi everyone,
I'm using datagrid control to display the data. I want to hide column to be
displayed into the data grid. I'm using the code as given below:
Method given below is used to bind the data grid with the db:
public static void DataGrid(DataGrid DG,string sql)
{
//Initialize connection with the db
SqlConnection co =initConnection();
SqlDataAdapter myCommand = new SqlDataAdapter(sql, co );
DataSet ds = new DataSet();
myCommand.Fill(ds);
DG.DataSource =ds.Tables[0].DefaultView;
co.Close();
}
clsGeneral.DataGrid(dgDestination,"Select strCode as Code, strName as Name,
acDestination from tblDestination where acDestination != 0");
// Set the DataGridTableStyle.MappingName property
// to the table in the data source to map to.
ts.MappingName = "tblDestination";
// Add it to the datagrid's TableStyles collection
// Create new DataGridColumnStyle objects.
DataGridColumnStyle acDestination = new DataGridTextBoxColumn();
acDestination.MappingName = "acDestination";
//cOrderDate.HeaderText = "Order Date";
acDestination.Width = 0;
ts.GridColumnStyles.Add(acDestination);
dgDestination.TableStyles.Add(ts);
dgDestination.Refresh();
I'm using the code as given in link below. I don't know what's wrong with
the code
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskaddingdeletingorhidingcolumns.asp
Thanks in advance...
Regards,
das
.
- Follow-Ups:
- Re: Hide datagrid column
- From: Philip Hristov
- Re: Hide datagrid column
- From: Dmytro Lapshyn [MVP]
- Re: Hide datagrid column
- Prev by Date: Re: convert int[] to byte[]
- Next by Date: Re: Unions in C Sharp
- Previous by thread: call from a webservice to a windows Form
- Next by thread: Re: Hide datagrid column
- Index(es):
Relevant Pages
|