可以實現在一個更簡單的方式:
<asp:DataList RepeatLayout="Table" RepeatColumns="2" RepeatDirection="Horizontal" runat="server" ID="dl">
<ItemTemplate>
<uc1:UCGroup ID="UCGroup1" runat="server" Title=<%# DataBinder.Eval(Container.DataItem, "RecipientGroup.Name") %> />
<div class="template_over">
<a href="/ScheduleCampaign/<%# DataBinder.Eval(Container.DataItem, "RecipientGroup.Name") %>">
<%# DataBinder.Eval(Container.DataItem, "Email") %>
</a>
</div>
</ItemTemplate>
</asp:DataList>
public partial class ChooseGroup : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
dl.DataSource = GroupsHndlr.GetExtendedRecipients(MySession.Current.ClientId);
dl.DataBind();
}
}
控件的代碼:
<asp:Label ID="lbltitle" runat="server"></asp:Label>
<asp:Repeater ID="rpRecipients" runat="server">
<ItemTemplate>
1
</ItemTemplate>
</asp:Repeater>
public partial class UCGroup : System.Web.UI.UserControl
{
public string Title { get; set; }
public List<string> Recipients { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
this.lbltitle.Text = Title;
this.rpRecipients.DataSource = Recipients;
this.rpRecipients.DataBind();
}
}
不知道爲什麼,但在代碼框中完全失敗了上面。我嘗試粘貼我的轉發器代碼,打字,包裝引號,並在其周圍放置代碼標籤。失敗。 – mokumaxCraig
您可以突出顯示代碼並按** {} **按鈕。 –
男人,這讓我瘋狂。感謝賈斯汀的信息! – mokumaxCraig