我有一个下拉列表,用于填充计算中的一组数据。我的 asp.net 站点中有多个页面,我想在主页上的下拉列表中显示带有当前数据的标签。这是我的代码...
''' In the page load'''
Dim Val As Double
If Date.Now.Month = 10 OrElse Date.Now.Month = 11 OrElse Date.Now.Month = 12 Then
Val = Date.Now.Year
Else
Val = Date.Now.Year - 1
End If
For i = Val To 1996 Step -1
dropdownlist1.Items.Add(i)
Next
End Sub
'''function in a seperate class'''
Function GetDates(currentYear As Double) As String
Dim x As String
Return x
End Function
'''In the selected index event of the drop down (populates years ie. 2011, 2010, 2009)'''
Dim x As String = class1.GetDates(dropdownlist1.Text)
'''In the other pages load events'''
Dim x As String = class1.GetDates(label1.Text)
上面这行代码是我想用当前年份(即 2011、2010、2009 年)填充的内容有什么建议吗?