Hide datagrid column

Tech-Archive recommends: Fix windows errors by optimizing your registry



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

.



Relevant Pages

  • Re: Hide datagrid column
    ... I mean what I did that I added the DataGridColumnStyle for other ... > Hi Das, ... >> I'm using datagrid control to display the data. ... >> displayed into the data grid. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Hyperlink in DataGrid
    ... derives from DataGridColumnStyle. ... to control how a column is rendered in the data grid. ... I need to show these numeric data as hyperlinks so that the> user can drill downward. ...
    (microsoft.public.dotnet.languages.csharp)
  • Formatting in a DataGrid
    ... I want to display +/- sign with the percentage value in the data grid. ... I have provide "0.000%" as the format for the datagridcolumnstyle. ...
    (microsoft.public.dotnet.languages.csharp)
  • Label control will not display information on one form entered on another.
    ... When I add the name of a new individual in a, bound form, it will not display ... that person?s name in a label control of a second unbound form. ... of registrations for different clients. ... existing entries that came with the data GRID module that I previously ...
    (microsoft.public.access.modulesdaovba)
  • Re: Label will not display NEW records frm another (bound) form.
    ... that person’s name in a label control of a second unbound form. ... Its purpose is to display the results ... past Registrations. ... This form contains a command button for accessing the data Grid for viewing ...
    (microsoft.public.access.formscoding)