0
我有以下的repeater項目:組轉發器爲每個不同的用戶
<asp:Repeater ID="RptLeaveRequests" runat="server"
onitemdatabound="RptLeaveRequests_ItemDataBound">
<ItemTemplate>
<table id="tableItem" runat="server">
<tr>
<td style="width: 100px;">
<asp:Label ID="lblDate" runat="server" Text='<%#Eval("Date", "{0:dd/M/yyyy}") %>'></asp:Label>
</td>
<td style="width: 100px;">
<asp:Label ID="lblHours" runat="server" Text='<%#Eval("Hours") %>'></asp:Label>
</td>
<td style="width: 200px;">
<asp:Label ID="lblPeriod" runat="server" Text='<%#Eval("AMorPM") %>'></asp:Label>
</td>
<td style="width: 200px; font-size:10px;">
<asp:Label ID="lblNote" runat="server" Text='<%#Eval("Note") %>'></asp:Label>
</td>
<td style="50px">
<asp:RadioButtonList ID="rbtVerified" runat="server" >
<asp:ListItem Value="1">Accept</asp:ListItem>
<asp:ListItem Value="2">Reject</asp:ListItem>
</asp:RadioButtonList>
</td>
<td>
<asp:TextBox ID="txtNotes" runat="server" ></asp:TextBox>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
在頁面加載我綁定的Repeater
else if(Convert.ToInt32(Session["UserLevel"]) != 0 && Convert.ToInt32(Session["UserLevel"]) < 151)
{
RptLeaveRequests.DataSource = newLeaveLogic().GetManagerUnverifiedLeaveRequests(Convert.ToInt32(Context.User.Identity.Name));
RptLeaveRequests.DataBind();
hasRequests = true;
}
現在組如何能夠返回爲每個不同的用戶的轉發器項目由GetManagerUnferifiedLeaveRequests返回一個DataTable的方法如下:
protected void RptLeaveRequests_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (hasRequests)
{
//grouping
}
}
你是什麼意思的分組? –
每個不同用戶的組數據。例如,用戶可以有多個請假請求,從而顯示用戶的姓名,並在其下面顯示用戶提出的所有請求,類似於此,但不是Ticker01和02,我需要用戶名:http://aspnettuts.files .wordpress.com/2010/10/repeater-group.gif?w = 595 – user1986761
這裏有一個幾乎完全相同的完整示例:http://stackoverflow.com/questions/11653190/grouped-gridview-with-expandable-groups/11657327#11657327 – Icarus