例如说如果我有一个业务实体 - >客户,它具有customerId
,customerName
和customerType
。我创建了一个asp:隐藏变量hdnCustomer runat =“服务器”将业务实体分配给隐藏变量
如果我想将客户业务实体的值(在后面的代码中)序列化到hdnCustomer,那么我该如何做?还有一次序列化,我将如何反序列化它?
// Pseudo code
Collection<Customer> customerList = new Collection<Customer>();
customerList = BusinessAccess.GetCustomerList();
hdnCustomer = serialize and assign the value of 'customerList' to hdnCustomer;
...
...
// Later on a select index change of one of the drop down lists
内的下拉列表中选择事件处理程序:
{
Collection<Customer> customerList = new Collection<Customer>();
customerList = deserialize the value from hdnCustomer
int a = Convert.ToInt32(ddlDropDown.SelectedValue);
foreach(a in customerList)
{
// Do something
}
}