Case statement in multiple methods My page contains: GridView1, GridView2, Button1, Button2, DropDownList1 I bind Gridviews to the table selected in dropdown like this:

Dim results as DataTable
Select Case ddl1.SelectedValue
    Case 0
        Dim cl as ClassZero = new ClassZero()
        results = cl.GetClassZeroNames()
    Case 1
           Dim cl as ClassOne = new ClassOne()
        results = cl.GetClassOneNames()
    Case 2
         Dim cl as ClassTwo = new ClassTwo()
        results = cl.GetClassTwoNames()
End Select
GridView1.DataSource = results
GridView1.DataBind()


Then I have two buttons with the following code:

Protected Sub btn1_Click(sender As Object, e As EventArgs) Handles btn2.Click
    Select Case ddl1.SelectedValue
        Case 0
             Dim cl as ClassZero = new ClassZero()
        results = cl.RunInsert()
        Case 1
             Dim cl as ClassOne = new ClassOne()
        results = cl.RunInsert()
        Case 2
             Dim cl as ClassTwo = new ClassTwo()
        results = cl.RunInsert()
    End Select
End Sub


And

Protected Sub btn2_Click(sender As Object, e As EventArgs) Handles btn2.Click
    Select Case ddl1.SelectedValue
        Case 0
             Dim cl as ClassZero = new ClassZero()
        results = cl.RemoveFromZero()
        Case 1
            Dim cl as ClassOne = new ClassOne()
        results = cl.RemoveFromOne()
        Case 2
            Dim cl as ClassTwo = new ClassTwo()
        results = cl.RemoveFromTwo()
    End Select
End Sub


For me it looks like a lot of overhead. How can I improve then design and only specify that I'm working on the following record in dropdown list without specifying the Case condition every time? Should I change my design or leave it like it is?

RunZero, RunOne, RunTwo, RemoveZero, RemoveOne, RemoveTwo, RemoveThree - Execute six different stored procedures.
You could use delegates. Set delegates in the Change event of ddl1, then you can always call the same delegates in your button handlers. This way you only need a switch in ddl1 Change event, and your button handlers will become much cleaner. However, even though this would make the code much more maintainable/readable, it'd probably be less efficient, though you still wouldn't be able to feel the difference in UI handlers.

Update: example added

Something along these lines (not copy&amp;paste):

Public Delegate Function CreateClassDelegate() As NumberClass

Public Class Form
    Public CreateClass As CreateClassDelegate

    Private Sub ddl1_SelectedValueChanged(sender As Object, e As EventArgs)
        Select Case Integer.Parse(TryCast(ddl1.SelectedItem, String))
            Case 0
                CreateClass = New CreateClassDelegate(AddressOf ClassZero.CreateClassZero)
                Exit Select
            Case 1
                CreateClass = new CreateClassDelegate(AddressOf ClassOne.CreateClassOne);
                Exit Select
            Case 2
                CreateClass = new CreateClassDelegate(AddressOf ClassTwo.CreateClassTwo);
                Exit Select
        End Select
    End Sub

    Private Sub btn1_Click(sender As Object, e As EventArgs)
        Dim cl As NumberClass = CreateClass()
        cl.GetNames()
    End Sub

    Private Sub btn2_Click(sender As Object, e As EventArgs)
        Dim cl As NumberClass = CreateClass()
        cl.RunInsert()
    End Sub
End Class

Public MustInherit Class NumberClass
    Public MustOverride Function GetNames() As List(Of String)
    Public MustOverride Sub RunInsert()
    Public MustOverride Sub Remove()
End Class

Public Class ClassZero
    Inherits NumberClass
    Public Overrides Function GetNames() As List(Of String)
         ...
        Return Nothing
    End Function
    Public Overrides Sub RunInsert()
             ...
    End Sub
    Public Overrides Sub Remove()
         ...
    End Sub

    Public Shared Function CreateClassZero() As ClassZero
        Return New ClassZero()
    End Function
End Class

' ... same as above for ClassOne, ClassTwo