从ListBox中获取所选对象

时间:2016-08-12 07:57:39

标签: vb.net

我正在尝试根据列表框中的选定项目检索对象,执行以下操作

    lstAvailableAppointments.DataTextField = "AppointmentDetails"
    lstAvailableAppointments.DataSource = appointments
    lstAvailableAppointments.DataBind()

    If lstAvailableAppointments.SelectedItem IsNot Nothing Then
    Dim appointmentDetails = TryCast(lstAvailableAppointments.SelectedItem, AppointmentHelper)
    End If

但我得到一个错误,说我无法将列表框项目转换为约会帮助

0 个答案:

没有答案