[英]Multiple class properties to display in listbox datatextfield
I'm currently trying to join two class properties inside an asp.net ListBox Control. 我目前正在尝试在asp.net ListBox控件中加入两个类属性。 I want to display the date then whether or not the appointment is AM/PM. 我想显示日期,然后显示约会是否为AM / PM。 Is this possible? 这可能吗? Thank 谢谢
Chris 克里斯
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()
Yes, go to your class and add a property with a getter. 是的,去上课并添加带有吸气剂的属性。 Then, in your getter body, just write 然后,在您的吸气剂体内,只需写
String.format("{0} {1}", First Property, SecondProperty);
Then just reference that new property as the text field. 然后,只需将该新属性作为文本字段引用即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.