0
我運行下面的查詢:如何使用VB.NET DataBind多個項目?
' Show which halls they are eligible for.
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, actual_available = sh.max_occupancy - sh.current_occupancy
)
rptrRooms.DataSource = selectedRooms
rptrRooms.DataBind()
其中,你可以看到,被綁定到一箇中繼器。現在,它包含多個值,我想在一個很好的格式化的方式來顯示它們,下面僞代碼:
<asp:Repeater ID="rptrRooms" runat="server" OnItemCommand="Choose_Room">
<ItemTemplate>
<asp:Button ID="btnChooseRoom" runat="server"
CommandName="<%# Container.DataItem.Room1.ToString %>" Text="<%# Container.DataItem.Room1 %> : Available : <%# Container.DataItem.actual_available %>"
/>
</ItemTemplate>
</asp:Repeater>
我給一個嘗試,但它不」 t喜歡雙重「」,所以我改變了內部的''。它運行但返回了以下錯誤: BC30201:預期的表達式。 來源錯誤: 第6行 第7行: 第8行:」Text =「<%#String.Format('{0}:Available:{1}',Container.DataItem .Room1,Container.DataItem.actual_available)%>「 第10行: –
davemackey
2011-03-12 15:44:36
好的,這真的很愚蠢 - 我只需要將引號反轉 - 現在外層是」內層「,它工作得很好。謝謝你的幫助! – davemackey 2011-03-12 15:46:28