私はcrmアプリケーションを持っています。リピーターコントロールをメッセージスレッドとしてバインドする方法に1つの問題があります。最初のスレッドを質問として、2 番目のスレッドをその質問の回答として。ユーザーが複数の質問をした場合、1 番目、2 番目、.. スレッドを質問として、メッセージ チャットのように...
データベースからデータを保持するために、次のストアド プロシージャを使用します。
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[ViewMessageThreads] (@inquiry_id varchar(50))
AS
BEGIN
SET NOCOUNT ON;
select
i.body as master_body,
h.body as history_body,
q.body as question_body,
q.Created_date as question_timestamp,
a.body as answer_body,
a.Created_date as answer_timestamp,
t.Type_name as user_type
from tbl_Inquiry_History i
left join tbl_Inquiry_master h on h.Inquiry_id=i.Inquiry_id
left join tbl_Question q on q.Inquiry_id=i.Inquiry_id
left join tbl_Answer a on a.Question_id=q.Inquiry_id
left join tbl_User_master u on u.Id=i.User_id
left join tbl_Login_master l on l.Id=u.User_id
left join tbl_Type t on t.Id = l.type_id
where (i.Inquiry_id=@inquiry_id)
END
これにより、次のような結果が得られます。
master_body history_body question_body question_t.. answer_body answer_t.. user_type
__________________________________________________________________________________________
question 1 NULL question 1 2005-03-14... NULL NULL User
question 1 NULL question 2 2005-03-14... NULL NULL User
そして、リピーターのこのデザインソースを含めます:
<asp:Repeater ID="Repeater_Inquiry_Messages" runat="server">
<ItemTemplate>
<table id="ctl00_ContentPlaceHolder1_dl_ticketmsg" cellspacing="0" border="0" style="width:100%;border-collapse:collapse;">
<tbody><tr>
<td style="background-color:#F5F5FF;">
<table cellpadding="0" cellspacing="0" border="0">
<tbody><tr>
<td class="header">
<span id="ctl00_ContentPlaceHolder1_dl_ticketmsg_ctl00_lbl_msg_no"><%#Container.ItemIndex+1 %></span></td>
<td class="normaltext" valign="bottom">
<span id="ctl00_ContentPlaceHolder1_dl_ticketmsg_ctl00_lbl_tagline">Message By <b><asp:Label ID="lbl_user_t" runat="server" Text='<%#Eval("user_type")%>'/></b> on <asp:Label ID="lbldatetime" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "question_timestamp","{0:ddd, dd MMMM yyyy}")%>'/></span></td>
</tr>
<tr>
<td class="header">
</td>
<td class="normaltext" valign="bottom">
<b>Message :</b><br>
<span id="ctl00_ContentPlaceHolder1_dl_ticketmsg_ctl00_Label1"><asp:Label ID="lbl_inquiry_desc" runat="server" Text='<%#Eval("question_body")%>'/></span></td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</ItemTemplate>
<SeparatorTemplate>
<table>
<tr>
<td style="height:3px"></td>
</tr>
</table>
</SeparatorTemplate>
<ItemTemplate>
<table id="ctl00_ContentPlaceHolder1_dl_ticketmsg1" cellspacing="0" border="0" style="width:100%;border-collapse:collapse;">
<tbody><tr>
<td style="background-color:#F5F5FF;">
<table cellpadding="0" cellspacing="0" border="0">
<tbody><tr>
<td class="header">
<span id="ctl00_ContentPlaceHolder1_dl_ticketmsg1_ctl00_lbl_msg_no"><%#Container.ItemIndex+1 %></span></td>
<td class="normaltext" valign="bottom">
<span id="ctl00_ContentPlaceHolder1_dl_ticketmsg1_ctl00_lbl_tagline">Message By <b><asp:Label ID="Label1" runat="server" Text='<%#Eval("user_type")%>'/></b> on <asp:Label ID="Label2" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "answer_timestamp","{0:ddd, dd MMMM yyyy}")%>'/></span></td>
</tr>
<tr>
<td class="header">
</td>
<td class="normaltext" valign="bottom">
<b>Message :</b><br>
<span id="ctl00_ContentPlaceHolder1_dl_ticketmsg1_ctl00_Label1"><asp:Label ID="Label3" runat="server" Text='<%#Eval("answer_body")%>'/></span></td>
</tr>
<tr>
<td class="header">
</td>
<td class="normaltext" valign="bottom">
<b></b>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</ItemTemplate>
</asp:Repeater>
この 2 番目のメッセージ スレッドをコメントしている間、これは質問スレッドしか表示しません。 - - - - - - - - - - - - - - - - - - - - 更新しました - - - - - ------------------------------ 助けてください..
- - - - - - - - - - - - - - - - - - - -更新しました - - - - - ------------------------------
Server Error in '/OmInvestmentStockMarketing_new' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1026: ) expected
Source Error:
Line 162: <span id="ctl00_ContentPlaceHolder1_dl_ticketmsg_ctl00_lbl_msg_no"><%#Container.ItemIndex+1 %></span></td>
Line 163: <td class="normaltext" valign="bottom">
Line 164: <span id="ctl00_ContentPlaceHolder1_dl_ticketmsg_ctl00_lbl_tagline">Message By <b><asp:Label ID="lbl_user_t" runat="server" Text='<%# If(Eval("cargo2").ToString() Is "Admin", "You", Eval("cargo2"))%>'/></b>
Line 165: on <asp:Label ID="lbldatetime" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"cargo1","{0:ddd, dd MMMM yyyy}")%>'/></span></td>
Line 166: </tr>
Source File: c:\Documents and Settings\Vishal\My Documents\Visual Studio 2005\WebSites\OmInvestmentStockMarketing_new\Admin\OWM_Inquiry.aspx Line: 164
Show Detailed Compiler Output:
Show Complete Compilation Source:
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053
- - - - - - - - - - - - - -更新しました - - - - - - - - - - - ----------------------
<asp:Repeater ID="Repeater_Inquiry_Messages" runat="server">
<ItemTemplate>
<div style='display: <%# Container.ItemIndex == 0 ? "none" : "block" %>'>
<table id="ctl00_ContentPlaceHolder1_dl_ticketmsg" cellspacing="0" border="0" style="width:100%;border-collapse:collapse;">
<tbody><tr>
<td style="background-color:#F5F5FF;">
<table cellpadding="0" cellspacing="0" border="0">
<tbody><tr>
<td class="header">
<span id="ctl00_ContentPlaceHolder1_dl_ticketmsg_ctl00_lbl_msg_no"><%--<%#Container.ItemIndex+1 %>--%><%# Container.ItemIndex.ToString() == "0" ? int.Parse("1") : Container.ItemIndex %></span></td>
<td class="normaltext" valign="bottom">
<span id="ctl00_ContentPlaceHolder1_dl_ticketmsg_ctl00_lbl_tagline">Message By <b><asp:Label ID="lbl_user_t" runat="server" Text='<%# Eval("cargo2").ToString()=="Admin" ? "You" : Eval("cargo2") %>'></asp:Label></b>
on <asp:Label ID="lbldatetime" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"cargo1","{0:ddd, dd MMMM yyyy}")%>'/></span></td>
</tr>
<tr>
<td class="header">
</td>
<td class="normaltext" valign="bottom">
<b>Message :</b><br>
<span id="ctl00_ContentPlaceHolder1_dl_ticketmsg_ctl00_Label1"><asp:Label ID="lbl_inquiry_desc" runat="server" Text='<%#Eval("body")%>'/></span></td>
</tr>
<tr>
<td class="header">
</td>
<td class="normaltext" valign="bottom">
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</div>
</ItemTemplate>
<SeparatorTemplate>
<table>
<tr>
<td style="background-color:White;width:5px;">
<span id="Label2"></span>
</td></tr>
</table>
</SeparatorTemplate>
</asp:Repeater>