0

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

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Andreas5
0

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
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.