gpt4 book ai didi

asp.net - Repeater 内的 Gridview

转载 作者:行者123 更新时间:2023-12-02 05:11:05 25 4
gpt4 key购买 nike

我的页面上有一个转发器,链接到一个数据源,该数据源用团队填充转发器。我的目标是为每支球队创建一个标题,并为每支球队创建一个 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>

最佳答案

我知道我曾经使用过一种解决方法...

首先将你的隐藏字段放在你的转发器中并绑定(bind)你的 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>

关于asp.net - Repeater 内的 Gridview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5646482/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com