I have a AspxGriview on aspx page with id="grdManageFilterRoom". I am binding this grid by fetching some data from database. In case of any changes in Session["grdManageFilterRoom"] variable it is automatically reflected in Session["tmpGrdManageFilterRoom"] variable
I don’t know why it’s happening and I want to avoid this behavior. Any suggestion would be appreciated.
Session["grdManageFilterRoom"] = NameIdPairs<Int32>.GetRooms(companyCode, companyPersonID);
grdManageFilterRoom.DataSource = Session["grdManageFilterRoom"];
Session["tmpGrdManageFilterRoom"] = Session["grdManageFilterRoom"];
This:
makes both session variables point to same object (I’m guessing that
GetRoomsmethod returns reference type), basically it doesn’t matter if you are usingSession["tmpGrdManageFilterRoom"]orSession["grdManageFilterRoom"](because it is the same object).If want to prevent this, then you need to clone those object(s).