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(DataGr id 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.Data Grid(dgDestinat ion,"Select strCode as Code, strName as Name,
acDestination from tblDestination where acDestination != 0");
// Set the DataGridTableSt yle.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 DataGridColumnS tyle objects.
DataGridColumnS tyle acDestination = new DataGridTextBox Column();
acDestination.M appingName = "acDestination" ;
//cOrderDate.Head erText = "Order Date";
acDestination.W idth = 0;
ts.GridColumnSt yles.Add(acDest ination);
dgDestination.T ableStyles.Add( ts);
dgDestination.R efresh();
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/de...ingcolumns.asp
Thanks in advance...
Regards,
das