例如,如果我有一个业务实体 -> 客户,它有customerId
,customerName
和customerType
. 我创建了一个 asp:Hidden Variable hdnCustomer to runat="server"
如果我想将客户业务实体的值(在后面的代码中)序列化到 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
}
}