Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP.NET 2.0 Gridview Column Ordering

Reply
Thread Tools

ASP.NET 2.0 Gridview Column Ordering

 
 
John Walker
Guest
Posts: n/a
 
      05-22-2008
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 ContainersNotPickedUp As Int16 = 9
Public Shared ContainersNotPickedUp__Pct As Int16 = 10
Public Shared ContainersNotDelivered As Int16 = 11
Public Shared ContainersNotDelivered__Pct As Int16 = 12
Public Shared EmptiesNotPU As Int16 = 13
Public Shared EmptiesNotPU__Pct As Int16 = 14
Public Shared EmptiesNotReturned As Int16 = 15
Public Shared EmptiesNotReturned__Pct As Int16 = 16
Public Shared TotalMean As Int16 = 17
End Class

Thanks,
John

 
Reply With Quote
 
 
 
 
John Walker
Guest
Posts: n/a
 
      05-22-2008
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" <> wrote in message
> news:9AFA22E2-B473-4CF5-B457-...
>
> > 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<string, int> or Dictionary<int,
> string>...?
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
>
>

 
Reply With Quote
 
 
 
 
John Walker
Guest
Posts: n/a
 
      05-22-2008
"Mark Rae [MVP]" wrote:

> "John Walker" <> wrote in message
> news:08D1B2FF-9BF2-4143-B757-...
>
> [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<string, int> or
> >> Dictionary<int,
> >> string>...?

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

>
> http://msdn.microsoft.com/en-us/library/xfhwa508.aspx
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
>
>


I see how that could work for me as i could programmatically assign the
column order at runtime, though the great thing i find about using a Class is
that intellisense will show me all the column names of the class so i dont
have to remember the exact spelling.

For example,
dg.Columns(Cols.TruckerCode).Visible = False

i would just need to remember that Cols is my class and then i just choose
the column name from the list. i dont 100% understand the Dictionary but i
did not see how to do something similar with intellisense.
Thanks
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Z-Ordering (Morton ordering) question nbigaouette C Programming 2 11-06-2009 05:26 AM
Gridview - Dynamic Column Ordering John Walker ASP .Net Web Controls 0 09-19-2008 02:49 PM
gridview column values to another page via gridview hyperlink column Keith G Hicks ASP .Net 3 02-18-2008 06:17 AM
How to hide a GridView column when the column's Visible property does not support databinding? Keithb ASP .Net 2 10-27-2006 05:02 AM
ordering results by column leonardburton@gmail.com Python 1 09-18-2005 04:57 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57