G
Guest
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/d...n/html/vbtskaddingdeletingorhidingcolumns.asp
Thanks in advance...
Regards,
das
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/d...n/html/vbtskaddingdeletingorhidingcolumns.asp
Thanks in advance...
Regards,
das