3
我在我的頁面上有一箇中繼器,它與一個用團隊填充中繼器的數據源鏈接。我的目標是爲每個團隊創建一個標題,併爲每個團隊創建一個GridView來修改每個團隊的參與者。Repeater內的Gridviews
問題:gridview的數據源需要團隊的PK來從數據庫中獲取合適的玩家。我怎麼能通過他們?
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="odsTeam">
<ItemTemplate>
<h1>
<%# Eval("name") %>
with maximum of
<%# Eval("st_max") %>
players.</h1>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="participant_id"
DataSourceID="odsParticipant">
<Columns>
<asp:BoundField DataField="participant_id" HeaderText="participant_id" InsertVisible="False"
ReadOnly="True" SortExpression="participant_id" />
<asp:BoundField DataField="participant_category_id" HeaderText="participant_category_id"
SortExpression="participant_category_id" />
<asp:BoundField DataField="team_id" HeaderText="team_id" SortExpression="team_id" />
<asp:BoundField DataField="room_id" HeaderText="room_id" SortExpression="room_id" />
<asp:BoundField DataField="delegation_id" HeaderText="delegation_id" SortExpression="delegation_id" />
<asp:BoundField DataField="first_name" HeaderText="first_name" SortExpression="first_name" />
<asp:BoundField DataField="last_name" HeaderText="last_name" SortExpression="last_name" />
<asp:BoundField DataField="date_of_birth" HeaderText="date_of_birth" SortExpression="date_of_birth" />
<asp:BoundField DataField="gender" HeaderText="gender" SortExpression="gender" />
<asp:BoundField DataField="identification_number" HeaderText="identification_number"
SortExpression="identification_number" />
<asp:BoundField DataField="photo_url" HeaderText="photo_url" SortExpression="photo_url" />
<asp:BoundField DataField="squad_number" HeaderText="squad_number" SortExpression="squad_number" />
<asp:BoundField DataField="length" HeaderText="length" SortExpression="length" />
<asp:BoundField DataField="weight" HeaderText="weight" SortExpression="weight" />
</Columns>
</asp:GridView>
</ItemTemplate>
</asp:Repeater>
<asp:ObjectDataSource ID="odsTeam" runat="server" OldValuesParameterFormatString="original_{0}"
OnSelecting="odsTeam_Selecting" SelectMethod="GetTeamsByDelegationID" TypeName="TeamBLL">
<SelectParameters>
<asp:Parameter Name="delegation_id" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="odsParticipant" runat="server" DeleteMethod="Delete" InsertMethod="Insert"
OldValuesParameterFormatString="original_{0}" SelectMethod="GetParticipantsByTeamID"
TypeName="ERASTableAdapters.tbl_participantTableAdapter"
UpdateMethod="Update" onselecting="odsParticipant_Selecting">
<DeleteParameters>
<asp:Parameter Name="Original_participant_id" Type="Int32" />
<asp:Parameter Name="Original_participant_category_id" Type="String" />
<asp:Parameter Name="Original_team_id" Type="Int32" />
<asp:Parameter Name="Original_room_id" Type="Int32" />
<asp:Parameter Name="Original_delegation_id" Type="Int32" />
<asp:Parameter Name="Original_first_name" Type="String" />
<asp:Parameter Name="Original_last_name" Type="String" />
<asp:Parameter Name="Original_date_of_birth" Type="DateTime" />
<asp:Parameter Name="Original_gender" Type="String" />
<asp:Parameter Name="Original_identification_number" Type="String" />
<asp:Parameter Name="Original_photo_url" Type="String" />
<asp:Parameter Name="Original_squad_number" Type="Int32" />
<asp:Parameter Name="Original_length" Type="Decimal" />
<asp:Parameter Name="Original_weight" Type="Decimal" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="participant_category_id" Type="String" />
<asp:Parameter Name="team_id" Type="Int32" />
<asp:Parameter Name="room_id" Type="Int32" />
<asp:Parameter Name="delegation_id" Type="Int32" />
<asp:Parameter Name="first_name" Type="String" />
<asp:Parameter Name="last_name" Type="String" />
<asp:Parameter Name="date_of_birth" Type="DateTime" />
<asp:Parameter Name="gender" Type="String" />
<asp:Parameter Name="identification_number" Type="String" />
<asp:Parameter Name="photo_url" Type="String" />
<asp:Parameter Name="squad_number" Type="Int32" />
<asp:Parameter Name="length" Type="Decimal" />
<asp:Parameter Name="weight" Type="Decimal" />
<asp:Parameter Name="Original_participant_id" Type="Int32" />
<asp:Parameter Name="Original_participant_category_id" Type="String" />
<asp:Parameter Name="Original_team_id" Type="Int32" />
<asp:Parameter Name="Original_room_id" Type="Int32" />
<asp:Parameter Name="Original_delegation_id" Type="Int32" />
<asp:Parameter Name="Original_first_name" Type="String" />
<asp:Parameter Name="Original_last_name" Type="String" />
<asp:Parameter Name="Original_date_of_birth" Type="DateTime" />
<asp:Parameter Name="Original_gender" Type="String" />
<asp:Parameter Name="Original_identification_number" Type="String" />
<asp:Parameter Name="Original_photo_url" Type="String" />
<asp:Parameter Name="Original_squad_number" Type="Int32" />
<asp:Parameter Name="Original_length" Type="Decimal" />
<asp:Parameter Name="Original_weight" Type="Decimal" />
</UpdateParameters>
<SelectParameters>
<asp:Parameter Name="team_id" Type="Int32" />
</SelectParameters>
<InsertParameters>
<asp:Parameter Name="participant_category_id" Type="String" />
<asp:Parameter Name="team_id" Type="Int32" />
<asp:Parameter Name="room_id" Type="Int32" />
<asp:Parameter Name="delegation_id" Type="Int32" />
<asp:Parameter Name="first_name" Type="String" />
<asp:Parameter Name="last_name" Type="String" />
<asp:Parameter Name="date_of_birth" Type="DateTime" />
<asp:Parameter Name="gender" Type="String" />
<asp:Parameter Name="identification_number" Type="String" />
<asp:Parameter Name="photo_url" Type="String" />
<asp:Parameter Name="squad_number" Type="Int32" />
<asp:Parameter Name="length" Type="Decimal" />
<asp:Parameter Name="weight" Type="Decimal" />
</InsertParameters>
</asp:ObjectDataSource>
謝謝!還有一個問題:有沒有辦法在設計模式下修改你的gridview,因爲中繼器不會在VS2008的設計模式中顯示gridview:D – Jeroen 2011-04-13 09:19:54
不,你不能在中繼器中這樣做。但是有一種方法,你可以把這個gridview帶到另一個頁面,並在那裏修改,然後再從那裏拷貝那個源到這個頁面。 – 2011-04-13 09:23:35
好的!非常感謝你 – Jeroen 2011-04-13 09:26:18