我在Iron Speed中使用DropDownlist。我的问题是它总是返回选择中的第一项,即使我使用page.ispostback。这是我的代码:
Protected Overrides Sub PopulatePaidbyCompPeriodDropDownList(
_ByVal selectedValue As String,
_ByVal maxItems As Integer)
Me.PaidbyCompPeriod.Items.Clear()
If (Not Page.IsPostBack) Then
Dim connectionString As String = ConfigurationManager
.ConnectionStrings("Database").ConnectionString
Dim conn As New SqlConnection(connectionString)
conn.Open()
Dim comm As SqlCommand = New SqlCommand("select distinct PeriodNumber,
CONVERT(VARCHAR(10), perioddateto, 23) AS payrolldate,
YEAR(payrolldate) as yeardate from Payroll order by payrolldate
desc", conn)
Dim reader As SqlDataReader = comm.ExecuteReader
While reader.Read
PaidbyCompPeriod.Items.Add(New ListItem(MonthName(Month(CDate(
reader.GetString(1)))) & " " & Day(CDate(reader.GetString(1)))
& ", " & Year(CDate(reader.GetString(1))), reader.GetInt32(0)
.ToString))
DropDownList.Items.Add(New ListItem(reader.GetString(0).ToString,
reader.GetString(1).ToString))
End While
reader.Close()
conn.Close()
PaidByCompDate.Text = CDate(PaidbyCompPeriod.SelectedItem.Text)
.ToString("MM/dd/yyyy")
End If
End Sub
我该如何解决这个问题?