我的页面上有一个转发器,与一个用转发器填充转发器的数据源相连。我的目标是为每个团队创建一个标题,为每个团队创建一个gridview,以修改每个团队中的玩家。
问题: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>
答案 0 :(得分:0)
我知道一次使用过一次......
首先将隐藏字段放在转发器中并绑定您的id,然后在gridview数据源中提供隐藏字段控件作为选择参数:
<h1>
<%# Eval("name") %>
with maximum of
<%# Eval("st_max") %>
players.</h1>
<asp:HiddenField runat="server" ID="hdfId" Value='<%# Eval("TeamId") %>' />
<asp:ObjectDataSource ID="odsTeam" runat="server" OldValuesParameterFormatString="original_{0}"
OnSelecting="odsTeam_Selecting" SelectMethod="GetTeamsByDelegationID" TypeName="TeamBLL">
<SelectParameters>
<asp:ControlParameter PropertyName="value" Name="delegation_id" ControlID="hdfId" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>