I have one DropDownLis control in my Default.aspx page. In need add data from class, is it possible?

I tried below but failed.

Public Class Mainclass
    Public Shared Sub Fillvalue()
        Dim dpage As New _Default
        For i = 0 To 10
            dpage.MyList.items.add(i)
        Next i
    End Sub

End Class

Please suggest how i can do this?

Thank You

Hello, you can pass the DropDownList as a reference to the function like this:

App_Code/Class1.vb:

Imports Microsoft.VisualBasic

Public Class Class1
    Public Shared Sub Fillvalue(ByRef myList As DropDownList)
        For i = 0 To 10
            myList.Items.Add(i)
        Next
    End Sub
End Class

Default.aspx.vb:

Imports Class1
Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Fillvalue(DropDownList1)
    End Sub
End Class