【发布时间】:2011-03-09 20:28:56
【问题描述】:
我有一个这样的中继器:
<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 开放”等等
【问题讨论】:
-
您是否尝试过类似 Select New With {sh.room1, .actual_available = sh.max_occupancy - sh.current_occupancy}
标签: asp.net entity-framework data-binding repeater