我有一个ObjectDataSource
这样的声明:
<asp:ObjectDataSource ID="PaymentsDataSource"
runat="server"
DataObjectTypeName="Payment"
TypeName="PaymentAdapter"
SelectMethod="GetPayments">
<SelectParameters>
<asp:ControlParameter ControlID="StartDate"
PropertyName="Text"
Name="startDate"
Type="DateTime" />
<asp:ControlParameter ControlID="EndDate"
PropertyName="Text"
Name="endDate"
Type="DateTime" />
<asp:ControlParameter ControlID="LocationCodes"
PropertyName="Items"
Name="selectedLocationCodes"
Type="Object" />
</SelectParameters>
</asp:ObjectDataSource>
控制问题是LocationCodes
这样声明的:
<select id="LocationCodes"
disabled="disabled"
runat="server"
class="chzn-container"
multiple=""
data-placeholder="Choose a Location Code(s)"
style="width: 100%;"
data-class="span10">
</select>
适配器上的服务器端Select
方法定义如下:
[DataObjectMethod(DataObjectMethodType.Select, true)]
public List<Payment> GetPayments(
DateTime startDate,
DateTime endDate,
object selectedLocationCodes)
{
}
现在,即使ListItemCollection
成功传递到Select
方法中并且方法中的代码Select
可以正常处理,仍然会被动地抛出以下错误Application_Error
。有没有办法忽略这个错误?
11/15/2012 13:37:49 168 (Machine=, App=34a846f1, Project=null, Dept=null, Thread=007, TraceLevel=1)
Exception Source: mscorlib
Exception Type: System.Runtime.Serialization.SerializationException
Exception Message: Type 'System.Web.UI.WebControls.ListItemCollection' in Assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable.