我使用会话来保存哈希表。它有不同的键值对,有些键引用'List'对象。
我在转发器控件中有不同的按钮来更改List的值,然后将其放回到哈希表中。然后使用相同的会话来保存该哈希表。但有时候会议中的变化会丢失。不知道为什么。我试过我的测试服务器。它可以正常工作。在Prod服务器上,我遇到了这个问题。
有什么建议吗?
<asp:Repeater ID="rptCountry" runat="server" OnItemDataBound="rptCountry_ItemDataBound" OnItemCommand="rptCountry_ItemCommand">
<ItemTemplate>
<asp:Button ID="btnCountry" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "Country").ToString() %>' CssClass="iButton Disabled" Enabled="false" UseSubmitBehavior="False" CommandName="Select" />
<asp:Label ID="hdnCountryCode" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "CountryCode")%>' Visible="false" />
</ItemTemplate>
</asp:Repeater>
protected void rptCountry_ItemCommand(object sender, RepeaterCommandEventArgs e)
{
if (e.CommandName.Equals("Select"))
{
Button btnCountry = (Button)e.Item.FindControl("btnCountry");
Label hdnCountryCode = (Label)e.Item.FindControl("hdnCountryCode");
if (Session["SearchFilter"] != null)
{
Hashtable htSearchFilter = (Hashtable)Session["SearchFilter"];
List<string> countries = (List<string>)htSearchFilter["Country"];
if (countries != null && countries.Count > 0)
{
bool countriesExists = false;
foreach (string country in countries)
{
if (country.Equals(hdnCountryCode.Text.Trim()))
{
countriesExists = true;
}
}
if (!countriesExists)
{
countries.Add(hdnCountryCode.Text.Trim());
btnCountry.CssClass = "iButton Active";
}
else
{
countries.Remove(hdnCountryCode.Text.Trim());
btnCountry.CssClass = "iButton";
}
}
else
{
countries.Add(hdnCountryCode.Text.Trim());
btnCountry.CssClass = "iButton Active";
}
htSearchFilter["Country"] = countries;
Session["SearchFilter"] = htSearchFilter;
ProvinceReloadControl(countries);
}
}
InitControl();
}