我有一个像这样的转发器:
<asp:Repeater ID="rptrRooms" runat="server" OnItemCommand="Choose_Room">
<ItemTemplate>
<asp:Button ID="btnChooseRoom" runat="server"
CommandName="<%# Container.DataItem.ToString %>" Text="<%# Container.DataItem %>"
/>
</ItemTemplate>
</asp:Repeater>
我将数据源绑定到转发器,如下所示:
Dim dbRooms As New pbu_housingEntities
Dim gender As String = Session("gender").ToString
Dim hall As String = CStr(Session("hall"))
Dim selectedRooms = (From sh In dbRooms.Rooms _
Where sh.gender = gender _
Where sh.current_occupancy < sh.max_occupancy _
Where sh.is_available = True _
Where sh.building_name = hall _
Select sh.room1
)
rptrRooms.DataSource = selectedRooms
rptrRooms.DataBind()
问题是,我还想向观众展示房间里可用的景点数量。但这需要以某种方式拉入current_occupancy / max_occupancy或执行计算(例如max_occupancy - current_occupancy = actual_available),然后将其返回到房间。
我正在寻找的最终结果是使用如下所示的文本返回按钮控件中的每个房间: “房间1 - 2开放”“房间8 - 1开放”等等
答案 0 :(得分:3)
谢谢davemackey :)这样的事情。
选择New With {sh.room1,.actual_available = sh.max_occupancy - sh.current_occupancy}
答案 1 :(得分:0)
Amit_g上面的评论是关键。我需要输入select语句actual_available = sh.max_occupancy - sh.current_occupancy。如果Amit发布了答案,我会将“正确”的答案更改为Amit,以便给出答案。 :)