我有一个表设置,每个数据条目都有一个唯一的Match_ID
。但是,当我想调用从Team
表中收集团队名称的自定义选择查询时,我会得到重复的行,列出两个相同的Match_ID
。我想在GridView中使用列Home team
,Away team
,Home team score
,Away team score
和Game date
唯一地显示行。我不想在他们的列中显示团队ID,而是他们的团队名称。但是我也想确保我可以更新这个GridView,因为使用AS阻止了我以前能够这样做。
这是我到目前为止使用的图片,显示了查询返回的内容。我正在使用SQL数据源。
SELECT MatchStatistics.Match_ID, MatchStatistics.Home_team_ID, MatchStatistics.Away_team_ID, MatchStatistics.Home_team_score, MatchStatistics.Away_team_score, MatchStatistics.Game_date,
Team.Team_name
FROM MatchStatistics INNER JOIN
Team ON MatchStatistics.Home_team_ID = Team.Team_ID OR MatchStatistics.Away_team_ID = Team.Team_ID
WHERE EXISTS
(SELECT DISTINCT Match_ID
FROM MatchStatistics AS MatchStatistics_1)
<asp:GridView ID="EnterMatchGridView" runat="server" AutoGenerateColumns="False" DataKeyNames="Match_ID" DataSourceID="SqlDataSource4" OnRowUpdating="EnterMatchGridView_RowUpdating" OnRowDeleting="EnterMatchGridView_RowDeleting">
<Columns>
<asp:BoundField DataField="Match_ID" HeaderText="Match_ID" SortExpression="Match_ID" InsertVisible="False" ReadOnly="True" />
<asp:TemplateField HeaderText="Home Team" SortExpression="Home_Team_Name">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Home_Team_Name") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Home_Team_Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Away Team" SortExpression="Away_Team_Name">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Away_Team_Name") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Away_Team_Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Home Team Score" SortExpression="Home_team_score">
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Home_team_score") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("Home_team_score") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Away Team Score" SortExpression="Away_team_score">
<EditItemTemplate>
<asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("Away_team_score") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("Away_team_score") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Date" SortExpression="Game_date">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Game_date", "{0:dd-MM-yyyy}") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("Game_date", "{0:dd-MM-yyyy}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Edit/Delete">
<ItemTemplate>
<asp:LinkButton ID="BtnEdit" runat="server" CausesValidation="false" CommandName="Edit" Text="Edit" />
<span onclick="return confirm ('Are you Sure?')">
<asp:LinkButton ID="BtnDelete" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete" />
</span>
</ItemTemplate>
<EditItemTemplate>
<asp:Button ID="BtnUpdate" runat="server" CausesValidation="true" CommandName="Update" ConflictDetection="OverwriteChanges" Text="Update" ValidationGroup="EnterMatchGridView" />
<asp:Button ID="BtnCancel" runat="server" CausesValidation="false" CommandName="Cancel" ConflictDetection="OverwriteChanges" Text="Cancel" />
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
简而言之,如何让此查询为每一行返回唯一的唯一MATCH_ID
?
答案 0 :(得分:2)
不会那样......
private void timer2_Tick(object sender, EventArgs e)
{
while (block.Left > (ClientSize.Width-ClientSize.Width))
{
Thread.Sleep(50); //how about putting sleep here for 50ms?
block.Left -= 1;
if (block.Left == (ClientSize.Width - ClientSize.Width))
{
break;
}
}
while (block.Right < ClientSize.Width)
{
Thread.Sleep(50); //how about putting sleep here for 50ms?
block.Left += 1;
if (block.Right == ClientSize.Width)
{
break;
}
}
}
???