Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Enums and web datagrid
Message
 
À
12/08/2003 19:36:59
Keith Payne
Technical Marketing Solutions
Floride, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00819602
Message ID:
00820203
Vues:
15
Thanks Keith.

The SortedList suggestion helped get me on the right track. I still thought it would be good to use the Enums for the sorted list so here is what I tried first:
Private Sub LoadSortedDepartmentList()

    Dim strEnumName As String

    For Each strEnumName In [Enum].GetNames(GetType(Departments))
	    slDepartments.Add(CType([Enum].Parse(GetType(Departments), strEnumName), Integer), SpaceCamelCase(strEnumName))
    Next

End Sub
Now if I ever added another value to the enum, it would be added to the sortedlist automatically. SpaceCamelCase is a method that turns a camelcase word like AllDepartments to All Departments.

Also your following suggestion helped me:
sl.IndexOfKey(DataBinder.Eval(Container, "DataItem.iDepartment"))
I ended up doing the following in the HTML of the datagrid, which allows me to not have to use a sorted list at all and still use the enum:
SpaceCamelCase([Enum].GetName(GetType(NewsMaintenance.Enums.Departments), (DataBinder.Eval(Container, "DataItem.iDepartment"))))
I am not sure if this way is better or worse than what you originally proposed. It is different though so I am not sure if there are potential problems with doing it this way. I would appreciate any comments about doing it this way versus using a sorted list.

Thanks,

Vic
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform