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. Web Development
  3. ASP.NET
  4. Hiding a column in datagrid

Hiding a column in datagrid

Scheduled Pinned Locked Moved ASP.NET
designhelpquestion
5 Posts 2 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.
  • C Offline
    C Offline
    chitranjan gohil
    wrote on last edited by
    #1

    Hello, How do i hide a column in datagrid.my columns are being auto populated and not been created at design time.i tried doing Datagrid1.Columns(1).visible=False,but it throws an error. Thank You, chitranjan more dash than cash!!!

    R 1 Reply Last reply
    0
    • C chitranjan gohil

      Hello, How do i hide a column in datagrid.my columns are being auto populated and not been created at design time.i tried doing Datagrid1.Columns(1).visible=False,but it throws an error. Thank You, chitranjan more dash than cash!!!

      R Offline
      R Offline
      RSArockiam
      wrote on last edited by
      #2

      You should do this after binding the datagrid. Since no more columns before binding the data when using autogeneratecolumns=true. Regards R.Arockiapathinathan

      C 1 Reply Last reply
      0
      • R RSArockiam

        You should do this after binding the datagrid. Since no more columns before binding the data when using autogeneratecolumns=true. Regards R.Arockiapathinathan

        C Offline
        C Offline
        chitranjan gohil
        wrote on last edited by
        #3

        Actually i m doing that after Datagrid1.Databind() only.still its throwing IndexOutOfBounds exception saying that there is no column at that position. more dash than cash!!!

        R 1 Reply Last reply
        0
        • C chitranjan gohil

          Actually i m doing that after Datagrid1.Databind() only.still its throwing IndexOutOfBounds exception saying that there is no column at that position. more dash than cash!!!

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

          Use ItemDataBound Event for this. The old method is applicable for autogeneratecolumns=false only. So inside the ItemDataBound Event, put following code: e.Item.Cells[0].Visible=false; Regards R.Arockiapathinathan

          C 1 Reply Last reply
          0
          • R RSArockiam

            Use ItemDataBound Event for this. The old method is applicable for autogeneratecolumns=false only. So inside the ItemDataBound Event, put following code: e.Item.Cells[0].Visible=false; Regards R.Arockiapathinathan

            C Offline
            C Offline
            chitranjan gohil
            wrote on last edited by
            #5

            hey thanx that worked fine Regards, chitranjan more dash than cash!!!

            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