将多个数据源合并到单个ASP.NET中继器?
我有一个这样的中继器:将多个数据源合并到单个ASP.NET中继器?,asp.net,entity-framework,data-binding,repeater,Asp.net,Entity Framework,Data Binding,Repeater,我有一个这样的中继器: <asp:Repeater ID="rptrRooms" runat="server" OnItemCommand="Choose_Room"> <ItemTemplate> <asp:Button ID="btnChooseRoom" runat="server" CommandName="<%# Container.DataItem.ToString %>" Text="<%# Con
<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()
我将数据源绑定到中继器,如下所示:
<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()
将数据室设置为新的pbu单元
将性别设置为字符串=会话(“性别”)。ToString
变光大厅作为字符串=CStr(会话(“大厅”))
Dim selectedRooms=(从数据库房间中的sh开始)。房间_
其中sh.gender=gender_
其中sh.当前占用率
问题是,我还想向观众展示房间中可用的斑点数量。但这需要以某种方式拉入当前入住率/最大入住率,或者执行计算(例如,最大入住率-当前入住率=实际可用入住率),然后将其与房间一起返回
我要寻找的最终结果是返回按钮控件中的每个房间,其中的文本如下所示:
“1-2号房间开放”、“8-1号房间开放”等等阿米特格的上述评论是关键。我需要在select语句中输入actual\u available=sh.max\u occulation-sh.current\u occulation。如果Amit发布了一个答案,我会将“正确”的答案改为Amit,为您的答案打分。:) 谢谢达维马克:)像这样的
使用{sh.room1,.actual\u available=sh.max\u occulation-sh.current\u occulation}选择新建您是否尝试过类似于使用{sh.room1,.actual\u available=sh.max\u occulation-sh.current\u occulation}选择新建的方法