I've got an FormView bound to an ObjectDataSource placed inside an usercontrol, initialized with the following code:
<asp:ObjectDataSource ID="odsCampaign" runat="server"
DataObjectTypeName="code.model.Campaign"
TypeName="code.model.Campaign"
SelectMethod="LoadCampaign">
<SelectParameters>
<asp:QueryStringParameter Name="code" QueryStringField="id" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
<%-- ... --%>
<asp:FormView ID="fvCampaign" runat="server"
DataSourceID="odsCampaign">
<EmptyDataTemplate>
<span>No campaign loaded.</span>
</EmptyDataTemplate>
<ItemTemplate>
<span>Campaign</span>
<span><%# Eval("Subject") %></span>
<%-- ... --%>
</ItemTemplate>
</asp:FormView>
My code behind looks something like this:
// CampaignCallCollection inherits from IEnumerable<CampaignCall>
public class Campaign : CampaignCallCollection
{
// Some property to show
public string Subject { get; set; }
// Constructor
public Campaign(int code)
: base()
{
// Initialize the object based on the primary key passed to the constructor
InitializeCampaign(code);
}
private void InitializeCampaign(int code)
{
// Initialization Code
}
// Loading method for ObjectDataSource
public static Campaign LoadCampaign(int code)
{
// Return new instance of an initialized campaign object.
Campaign oCampaign = new Campaign(code);
//throw new Exception(oCampaign.Subject);
return oCampaign;
}
}
However if I enable the exception the proper subject text is passed as exception message. But my FormView does allways render the EmptyTemplate. I do not really see mistake in here. Can anyone help me out with this?
Thanks in advance!
是因为它期望的是广告系列列表,而不是单个广告系列?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.