how to hide a column in a datagrid but autogenerated columns = "True"?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sri devi
    New Member
    • Sep 2010
    • 7

    #1

    how to hide a column in a datagrid but autogenerated columns = "True"?

    Hi Frnz,

    How to hide a column in a datagrid but, the property named Autogenerated Columns = "True". b'coz i want to add a datacolumn dynamically.... ... My Question is how to hide that columns??????
  • mzmishra
    Recognized Expert Contributor
    • Aug 2007
    • 390

    #2
    Code:
    DataTable dt new DataTable();
     
    DataColumn dcol new DataColumn(ID typeof(System.Int32));
    
    dcol.AutoIncrement true;
    
    dt.Columns.Add(dcol);
    
    
    
    dcol new DataColumn(NAME typeof(System.String));
    
    dt.Columns.Add(dcol);
    
    
    //Iterate through the columns of the datatable to set the data bound field dynamically.
    
    foreach (DataColumn col in dt.Columns)
    
    {
    
    
    BoundField bfield new BoundField();
    
    bfield.DataField col.ColumnName;
    
    bfield.HeaderText col.ColumnName;
    
    GrdDynamic.Columns.Add(bfield);
    
    }
    
    
    GrdDynamic.DataSource dt;
    
    GrdDynamic.DataBind();
    
    }[CODE]
    [/CODE]

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      DataGrid or DataGridView or GridView?
      DataGridView and GridView you can hide the columns after applying a datasource.
      I've never used the DataGrid object

      Comment

      • sri devi
        New Member
        • Sep 2010
        • 7

        #4
        how to hide a column in a datagrid but autogenerated columns = "True&quot ;?

        Hi Frnz,

        How to hide a column in a datagrid but, the property named Autogenerated Columns = "True". Because I want to add a datacolumn dynamically... My Question is how to hide that columns?

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          DataGridColumns have a .Visible property, try setting it to false

          Comment

          • sri devi
            New Member
            • Sep 2010
            • 7

            #6
            how to hide a column in a datagrid but autogenerated columns = "True&quot ;?

            First Thanks for ur response,i tried to do the following code. It helps more......

            DataSetname.Col umns.Remove("Co lumnName");

            Thanks,
            Sri Devi S

            Comment

            Working...