在列表框datatextfield中显示多个类属性

本文关键字:属性 显示 列表 datatextfield | 更新日期: 2023-09-27 18:01:54

我目前正在尝试在asp.net ListBox控件中加入两个类属性。我想显示日期,然后无论约会是上午/下午。这可能吗?谢谢

克里斯

Dim lstAppointments As List(Of AppointmentSlotInfo) = New List(Of     AppointmentSlotInfo)
Dim appointment1 As AppointmentSlotInfo = New AppointmentSlotInfo()
    With appointment1
        .AppointmentDate = DateTime.Now
        .AppointmentTimeSlot = "PM"
    End With
Dim appointment2 As AppointmentSlotInfo = New AppointmentSlotInfo()
    With appointment2
        .AppointmentDate = DateTime.Now.AddDays(1)
        .AppointmentTimeSlot = "AM"
    End With
lstAppointments.Add(appointment1)
lstAppointments.Add(appointment2)
lstAvailableAppointments.DataTextField = "AppointmentDate,AppointmentTimeSlot"
lstAvailableAppointments.DataSource = lstAppointments
lstAvailableAppointments.DataBind()

在列表框datatextfield中显示多个类属性

是的,在你的类中添加一个带有getter的属性。然后,在getter主体中,写入

String.format("{0} {1}", First Property,  SecondProperty);

然后引用这个新属性作为文本字段