SQL Server ビューからのレコードを表示するリストビューがあります。データは customerid によってフィルター処理され、ビューの実行時に 2 つの一意のレコードが含まれます。ただし、リストビューは最初のレコードのみを表示し、それを 2 回表示します。したがって、リストビューには 2 つのレコードが表示されますが、ビューによって生成された 2 つのレコードは表示されず、ビューの最初のレコードが 2 回表示されるだけです。これが明確であることを願っています。
何が起こっている?私は何時間も運が悪かった。
<asp:ListView ID="lstBeforeAfter" runat="server" DataKeyNames="CustomerID" InsertItemPosition="None">
<LayoutTemplate>
<div class="divreg">
<table ID="itemPlaceholderContainer" runat="server" cellpadding="2" class="tablebasic" style="vertical-align:top">
<tr ID="Tr1" runat="server" align="center">
<td style="background-color:#7e0d7d; color:White; font-size:1.2em; font-weight:bold; padding-top:4px; padding-bottom:4px">
Services
</td>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</div>
</td>
</LayoutTemplate>
<ItemTemplate>
<tr style="">
<td align="center">
<div class="divwrap">
<div class="left3ColHeader">
<b>Date</b>
</div>
<div class="mid3ColHeader">
<b>Stylist</b>
</div>
<div class="right3ColHeader">
<b>Services</b>
</div>
<div class="formclear">
</div>
<div class="left3ColBorder">
<%# Eval("SchedStartDateTime", "{0:d}")%>
</div>
<div class="mid3ColBorder">
<%#Eval("FullName")%>
</div>
<div class="right3ColBorder">
<%#Eval("ServiceText")%>
</div>
<div class="formclear">
</div>
<div class="left2ColHeader">
<b>Before Picture</b>
</div>
<div class="right2ColHeader">
<b>After Picture</b>
</div>
<div class="formclear">
</div>
<div class="left2ColPicBorder">
<asp:Image ID="imgLeft" ImageUrl='<%# Eval("BeforePicPath") %>' runat="server" />
</div>
<div class="right2ColPicBorder">
<asp:Image runat="server" ID="imgRight" ImageUrl='<%# Eval("AfterPicPath") %>' />
</div>
<div class="formclear">
</div>
<div class="left2ColBorder">
<asp:Label ID="lblBefore" Width="95%" runat="server" Text='<%# Eval("BeforePicName") %>'></asp:Label>
</div>
<div class="right2ColBorder">
<asp:Label ID="lblAfter" Width="95%" runat="server" Text='<%# Eval("AfterPicName") %>'></asp:Label>
</div>
<div class="formclear">
</div>
<div class="divreg">
<hr />
</div>
<div class="formclear">
</div>
</div>
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr style="background-color:#ffffd9">
<td align="center">
<div class="divwrap">
<div class="left3ColHeader">
<b>Date</b>
</div>
<div class="mid3ColHeader">
<b>Stylist</b>
</div>
<div class="right3ColHeader">
<b>Services</b>
</div>
<div class="formclear">
</div>
<div class="left3ColBorder">
<%# Eval("SchedStartDateTime", "{0:d}")%>
</div>
<div class="mid3ColBorder">
<%#Eval("FullName")%>
</div>
<div class="right3ColBorder">
<%# Eval("ServiceText").ToString%>
</div>
<div class="formclear">
</div>
<div class="left2ColHeader">
<b>Before Picture</b>
</div>
<div class="right2ColHeader">
<b>After Picture</b>
</div>
<div class="formclear">
</div>
<div class="left2ColPicBorder">
<asp:Image ID="imgLeft" ImageUrl='<%# Eval("BeforePicPath") %>' runat="server" />
</div>
<div class="right2ColPicBorder">
<asp:Image runat="server" ID="imgRight" ImageUrl='<%# Eval("AfterPicPath") %>' />
</div>
<div class="formclear">
</div>
<div class="left2ColBorder">
<asp:Label ID="lblBefore" Width="95%" runat="server" Text='<%# Eval("BeforePicName") %>'></asp:Label>
</div>
<div class="right2ColBorder">
<asp:Label ID="lblAfter" Width="95%" runat="server" Text='<%# Eval("AfterPicName") %>'></asp:Label>
</div>
<div class="formclear">
</div>
<div class="divreg">
<hr />
</div>
<div class="formclear"> </div>
</div>
</td>
</tr>
</AlternatingItemTemplate>
</asp:ListView>
Protected Sub LoadPortfolio(ByVal iCustID As Integer)
Dim dc As New SalonDataClassesDataContext
Dim q = From p In dc.vClientStyles Where p.CustomerID = iCustID Order By p.SchedStartDateTime Descending Select p
If q.Count > 0 Then
Me.lstBeforeAfter.DataSource = q
Me.lstBeforeAfter.DataBind()
End If
End Sub
SELECT ISNULL(dbo.Services.ServiceID, 0) AS ServiceID, dbo.Schedules.SchedStartDateTime, dbo.Schedules.ServiceText, dbo.Schedules.CustomerID,
ISNULL(dbo.Services.Completed, 0) AS Completed, dbo.Stylists.FullName, dbo.Stylists.StylistID, ISNULL(dbo.Services.BeforePicName, 'No Title') AS BeforePicName,
ISNULL(dbo.Services.BeforePicPath, '../images2020/resume-photo.jpg') AS BeforePicPath, ISNULL(dbo.Services.AfterPicName, 'No Title') AS AfterPicName,
ISNULL(dbo.Services.AfterPicPath, '../images2020/resume-photo.jpg') AS AfterPicPath
FROM dbo.Schedules INNER JOIN dbo.Stylists ON dbo.Schedules.UserID = dbo.Stylists.UserID LEFT OUTER JOIN dbo.Services ON dbo.Schedules.ServiceID = dbo.Services.ServiceID
ORDER BY dbo.Schedules.SchedStartDateTime DESC
ユニオンクエリに変更しましたが、linq は気に入りません。
SELECT ISNULL(dbo.Schedules.ServiceID, 0) AS ServiceID, dbo.Schedules.SchedStartDateTime, dbo.Schedules.ServiceText, dbo.Schedules.CustomerID,
ISNULL(dbo.Schedules.Completed, 0) AS Completed, dbo.Stylists.FullName, dbo.Stylists.StylistID, 'No Title' AS BeforePicName, '../images2020/resume-photo.jpg' AS BeforePicPath, 'No Title' AS AfterPicName, '../images2020/resume-photo.jpg' AS AfterPicPath
FROM dbo.Schedules INNER JOIN dbo.Stylists ON dbo.Schedules.UserID = dbo.Stylists.UserID
Where dbo.Schedules.CustomerID = 27
UNION
SELECT ISNULL(dbo.Services.ServiceID, 0) AS ServiceID, dbo.Schedules.SchedStartDateTime, dbo.Schedules.ServiceText, dbo.Schedules.CustomerID,
ISNULL(dbo.Services.Completed, 0) AS Completed, dbo.Stylists.FullName, dbo.Stylists.StylistID, ISNULL(dbo.Services.BeforePicName, 'No Title') AS BeforePicName,
ISNULL(dbo.Services.BeforePicPath, '../images2020/resume-photo.jpg') AS BeforePicPath, ISNULL(dbo.Services.AfterPicName, 'No Title') AS AfterPicName, ISNULL(dbo.Services.AfterPicPath, '../images2020/resume-photo.jpg') AS AfterPicPath
FROM dbo.Schedules INNER JOIN dbo.Stylists ON dbo.Schedules.UserID = dbo.Stylists.UserID INNER JOIN dbo.Services ON dbo.Schedules.ServiceID = dbo.Services.ServiceID
Where dbo.Schedules.CustomerID = 27 ORDER BY dbo.Schedules.SchedStartDateTime DESC
エラーが表示されます...クエリ結果を複数回列挙することはできません。
私は何を間違っていますか?ありがとう