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. urgent about DataGrid web control

urgent about DataGrid web control

Scheduled Pinned Locked Moved ASP.NET
5 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.
  • A Offline
    A Offline
    amir_iiui
    wrote on last edited by
    #1

    hi all... I want to delete column in a datagrid at runtime. Can some body tell me how i can do this. I have read the topic given on this web sight. but that approach only hides the column from displaying. while i want to delete the whole column.

    R M 2 Replies Last reply
    0
    • A amir_iiui

      hi all... I want to delete column in a datagrid at runtime. Can some body tell me how i can do this. I have read the topic given on this web sight. but that approach only hides the column from displaying. while i want to delete the whole column.

      R Offline
      R Offline
      R Thomas 0
      wrote on last edited by
      #2

      Why do u want to delete it? any particular reason? Hiding doesn't do it for you? "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18

      1 Reply Last reply
      0
      • A amir_iiui

        hi all... I want to delete column in a datagrid at runtime. Can some body tell me how i can do this. I have read the topic given on this web sight. but that approach only hides the column from displaying. while i want to delete the whole column.

        M Offline
        M Offline
        minhpc_bk
        wrote on last edited by
        #3

        You can delete the column with the Remove and RemoveAt methods of the DataGridColumnCollection class, for example:

        private void DeleteColumn(int colIndex)
        {
        DataGrid1.Columns.RemoveAt(colIndex);
        }

        However, you basically need to remove the column before the DataGrid control's state is reloaded and the control is rebuilt, otherwise it makes no changes to the column collection. In other words, you should remove the column in the Page_Init phase. So you'd better use the Visible property to display/hide a column. For more information see DataGridColumnCollection Class[^]

        A 1 Reply Last reply
        0
        • M minhpc_bk

          You can delete the column with the Remove and RemoveAt methods of the DataGridColumnCollection class, for example:

          private void DeleteColumn(int colIndex)
          {
          DataGrid1.Columns.RemoveAt(colIndex);
          }

          However, you basically need to remove the column before the DataGrid control's state is reloaded and the control is rebuilt, otherwise it makes no changes to the column collection. In other words, you should remove the column in the Page_Init phase. So you'd better use the Visible property to display/hide a column. For more information see DataGridColumnCollection Class[^]

          A Offline
          A Offline
          amir_iiui
          wrote on last edited by
          #4

          As for as 'Rohan' message is concerned.... i want to delete the column... it is my need.... simply hiding the column doesn't satisfy my requirements.... and as for as minhpc_bk message is concerned.... i tried this approach.... but it is not working well...... Can u please tell me in detail what do u mean by 'datagrid state is reloaded '..... actually, i have a datagrid given...... I have to copy it into another datagrid with last column of first grid doesn't come to the second grid.... for this purpose what i have to do.....

          M 1 Reply Last reply
          0
          • A amir_iiui

            As for as 'Rohan' message is concerned.... i want to delete the column... it is my need.... simply hiding the column doesn't satisfy my requirements.... and as for as minhpc_bk message is concerned.... i tried this approach.... but it is not working well...... Can u please tell me in detail what do u mean by 'datagrid state is reloaded '..... actually, i have a datagrid given...... I have to copy it into another datagrid with last column of first grid doesn't come to the second grid.... for this purpose what i have to do.....

            M Offline
            M Offline
            minhpc_bk
            wrote on last edited by
            #5

            amir_iiui wrote: Can u please tell me in detail what do u mean by 'datagrid state is reloaded '..... You can look at Control Execution Lifecycle[^] to see how a control is processed at the server side. amir_iiui wrote: I have to copy it into another datagrid with last column of first grid doesn't come to the second grid.... I am wondering why you have to copy a datagrid into another one, or in what situation you need to do that.

            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