Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. column hiding in Gridview

column hiding in Gridview

Scheduled Pinned Locked Moved C#
csharpasp-netwpfwcfhelp
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RanjithLogics
    wrote on last edited by
    #1

    Hi ... I am using one asp.net 2 Gridview control. I am binding it with a datatable. Now I want to hide two columns in the Gridview. How to do that ..Plz help me This is my code... DataTable dt = new DataTable("STEPS"); DataColumn dcOrder = new DataColumn("Order", typeof(Int32)); DataColumn dcName = new DataColumn("Name", typeof(string)); //Datacolumns are added to table dtsteps. dt.Columns.AddRange(new DataColumn[] {dcOrder, dcName); ..... //Assigning dtsteps as the datasource of my gridview dgsteps MyGridView.DataSource = dt; MyGridView.DataBind(); Thanks in advance....

    Ranjith

    A S 2 Replies Last reply
    0
    • R RanjithLogics

      Hi ... I am using one asp.net 2 Gridview control. I am binding it with a datatable. Now I want to hide two columns in the Gridview. How to do that ..Plz help me This is my code... DataTable dt = new DataTable("STEPS"); DataColumn dcOrder = new DataColumn("Order", typeof(Int32)); DataColumn dcName = new DataColumn("Name", typeof(string)); //Datacolumns are added to table dtsteps. dt.Columns.AddRange(new DataColumn[] {dcOrder, dcName); ..... //Assigning dtsteps as the datasource of my gridview dgsteps MyGridView.DataSource = dt; MyGridView.DataBind(); Thanks in advance....

      Ranjith

      A Offline
      A Offline
      AB7771
      wrote on last edited by
      #2

      just do the following: datagrdview.Columns[0].Width = 0; this will hide the 0th column of the datagridview.

      Thanks & Regards, Pramod "Everyone is a genius at least once a year"

      R 1 Reply Last reply
      0
      • R RanjithLogics

        Hi ... I am using one asp.net 2 Gridview control. I am binding it with a datatable. Now I want to hide two columns in the Gridview. How to do that ..Plz help me This is my code... DataTable dt = new DataTable("STEPS"); DataColumn dcOrder = new DataColumn("Order", typeof(Int32)); DataColumn dcName = new DataColumn("Name", typeof(string)); //Datacolumns are added to table dtsteps. dt.Columns.AddRange(new DataColumn[] {dcOrder, dcName); ..... //Assigning dtsteps as the datasource of my gridview dgsteps MyGridView.DataSource = dt; MyGridView.DataBind(); Thanks in advance....

        Ranjith

        S Offline
        S Offline
        shopi30
        wrote on last edited by
        #3

        This is the better method. dt.Columns["{COLUMN_NAME}"].ColumnMapping = MappingType.Hidden;

        SINCERELY. ANTHONY ACUÑA PREFERED PHRASE: SOMEBODY TELL ME WHY IS MORE REAL WHEN I DREAM THAT I AM WAKE?

        R 1 Reply Last reply
        0
        • A AB7771

          just do the following: datagrdview.Columns[0].Width = 0; this will hide the 0th column of the datagridview.

          Thanks & Regards, Pramod "Everyone is a genius at least once a year"

          R Offline
          R Offline
          RanjithLogics
          wrote on last edited by
          #4

          There is no property "Width" for datagridview.columns. There i found a visible property but it doesnt work :(

          Ranjith

          A 1 Reply Last reply
          0
          • R RanjithLogics

            There is no property "Width" for datagridview.columns. There i found a visible property but it doesnt work :(

            Ranjith

            A Offline
            A Offline
            AB7771
            wrote on last edited by
            #5

            this is what u have to do after setting the data to the datagrid. dataGridView1.Columns[0].Width = 0; This should be enough

            Thanks & Regards, Pramod "Everyone is a genius at least once a year"

            R 1 Reply Last reply
            0
            • S shopi30

              This is the better method. dt.Columns["{COLUMN_NAME}"].ColumnMapping = MappingType.Hidden;

              SINCERELY. ANTHONY ACUÑA PREFERED PHRASE: SOMEBODY TELL ME WHY IS MORE REAL WHEN I DREAM THAT I AM WAKE?

              R Offline
              R Offline
              RanjithLogics
              wrote on last edited by
              #6

              I tried this way also.. But it is not working :(

              Ranjith

              1 Reply Last reply
              0
              • A AB7771

                this is what u have to do after setting the data to the datagrid. dataGridView1.Columns[0].Width = 0; This should be enough

                Thanks & Regards, Pramod "Everyone is a genius at least once a year"

                R Offline
                R Offline
                RanjithLogics
                wrote on last edited by
                #7

                But I couldnt find any property Width for "dataGridView1.Columns[0]"

                Ranjith

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups