ASP.NET 2.0 Gridview Column Ordering

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?Sm9obiBXYWxrZXI=?=

    ASP.NET 2.0 Gridview Column Ordering

    Hi,

    In ASP.NET 2.0 I have a class called Cols (shown below) which keeps a record
    of the different columns in my gridview. I need this because sometimes I
    need to show/hide columns and need to know their position. One problem with
    this is that whenever we add a column to the gridview i need to add it to
    this Cols class and if it's at the beginning then every column after it has
    to be renumbered.
    Is there a way to somehow have the Cols fields auto number themselves, or is
    there an overall better way to keep track of your columns so it's easy to
    locate them for showing/hiding?

    Public Class Cols
    Public Shared Office As Int16 = 1
    Public Shared TruckerName As Int16 = 2
    Public Shared TruckerCode As Int16 = 3
    Public Shared TotalContainers As Int16 = 4
    Public Shared DOsNotReceived As Int16 = 5
    Public Shared DOsNotReceived_ _Pct As Int16 = 6
    Public Shared DOsPastDue As Int16 = 7
    Public Shared DOsPastDue__Pct As Int16 = 8
    Public Shared ContainersNotPi ckedUp As Int16 = 9
    Public Shared ContainersNotPi ckedUp__Pct As Int16 = 10
    Public Shared ContainersNotDe livered As Int16 = 11
    Public Shared ContainersNotDe livered__Pct As Int16 = 12
    Public Shared EmptiesNotPU As Int16 = 13
    Public Shared EmptiesNotPU__P ct As Int16 = 14
    Public Shared EmptiesNotRetur ned As Int16 = 15
    Public Shared EmptiesNotRetur ned__Pct As Int16 = 16
    Public Shared TotalMean As Int16 = 17
    End Class

    Thanks,
    John

  • Mark Rae [MVP]

    #2
    Re: ASP.NET 2.0 Gridview Column Ordering

    "John Walker" <JohnWalker@dis cussions.micros oft.comwrote in message
    news:9AFA22E2-B473-4CF5-B457-28DEC6A69ECE@mi crosoft.com...
    Is there a way to somehow have the Cols fields auto number themselves, or
    is
    there an overall better way to keep track of your columns so it's easy to
    locate them for showing/hiding?
    I have to say I'm scratching my head as to why you need a separate class
    just for this...?

    Why not just use a generic e.g. Dictionary<stri ng, intor Dictionary<int,
    string>...?


    --
    Mark Rae
    ASP.NET MVP


    Comment

    • =?Utf-8?B?Sm9obiBXYWxrZXI=?=

      #3
      Re: ASP.NET 2.0 Gridview Column Ordering

      Mark,
      Would you please give me an example of how to use Dictionary? I've never
      used that before.
      Thanks

      "Mark Rae [MVP]" wrote:
      "John Walker" <JohnWalker@dis cussions.micros oft.comwrote in message
      news:9AFA22E2-B473-4CF5-B457-28DEC6A69ECE@mi crosoft.com...
      >
      Is there a way to somehow have the Cols fields auto number themselves, or
      is
      there an overall better way to keep track of your columns so it's easy to
      locate them for showing/hiding?
      >
      I have to say I'm scratching my head as to why you need a separate class
      just for this...?
      >
      Why not just use a generic e.g. Dictionary<stri ng, intor Dictionary<int,
      string>...?
      >
      >
      --
      Mark Rae
      ASP.NET MVP

      >
      >

      Comment

      • Mark Rae [MVP]

        #4
        Re: ASP.NET 2.0 Gridview Column Ordering

        "John Walker" <JohnWalker@dis cussions.micros oft.comwrote in message
        news:08D1B2FF-9BF2-4143-B757-50931556CDC1@mi crosoft.com...

        [top-posting corrected]
        >>Is there a way to somehow have the Cols fields auto number themselves,
        >>or
        >>is there an overall better way to keep track of your columns so it's
        >>easy to
        >>locate them for showing/hiding?
        >>
        >I have to say I'm scratching my head as to why you need a separate class
        >just for this...?
        >>
        >Why not just use a generic e.g. Dictionary<stri ng, intor
        >Dictionary<int ,
        >string>...?
        >
        Would you please give me an example of how to use Dictionary? I've never
        used that before.



        --
        Mark Rae
        ASP.NET MVP


        Comment

        Working...