- 25 hours to Bariloche, but the views are worth it. https://t.co/7W7cN2t1sm 22 hours ago
- RT @SaintGimp: GWB: "No democracy pretends to be a tyranny. Most tyrannies pretend to be democracies. Democracy remains definition of polit… 2 days ago
- Seattle, WA ✈️ Atlanta, GA ✈️ Buenos Aires, Argentina ✈️ San Carlos de Baroloche, Argentina #AdventureTime @nodeconfar we are on our way! 2 days ago
- RT @aaronpk: Super happy to announce that my book "OAuth 2.0 Simplified" is now available! oauth2simplified.com 3 days ago
- RT @GraceStarling4: For those carrying their #MeToo with them silently, you are loved, cherished, and believed. You do not owe your story t… 4 days ago
Overkill or Useless: You Decide!
January 30, 2009Posted by on
Here is the gist of what I was trying to accomplish. Please excuse the VB.. it’s not by choice. 8)
Basically the page I was working on has a set of switch statements based on string literals which annoys me.. So I was messing around with a way to use Enumerations to represent my commands. But the commands come back as strings from the various page controls.. So I was looking at a way to generically re-map back to the command Enumeration.
Private Function GetCommand(Of T)(ByVal commandName As String) As T Return CType([Enum].Parse(GetType(T), commandName), T) End Function Protected Enum GridCommand CompetencySelect FormSelect Sort End Enum Public Overrides Sub Grid_Commands(ByVal source As Object, _ ByVal e As DataGridCommandEventArgs) _ Handles CompetencyData.ItemCommand, FormData.ItemCommand If Page_Save() Then Select Case GetCommand(Of GridCommand)(e.CommandName) Case GridCommand.CompetencySelect NavigateToCompetencySelection( _ CInt(CompetencyData.DataKeys(e.Item.ItemIndex)), _ CompetencyData.ID) Case GridCommand.FormSelect NavigateToFormSelection( _ CInt(FormData.DataKeys(e.Item.ItemIndex)), _ FormData.ID) End Select End If End Sub