Last post Feb 19, 2016 08:02 AM by Yohann Lu
Feb 18, 2016 10:03 PM|shahid.majeed|LINK
I am presenting a available rooms in gridview which is in modal popup. Basically gridview shows all available rooms of all building. I have two drop down list to filter the gridview for building and floor. Which basic shows the available rooms of specific
building and floor to filter the rooms.
Available rooms shows in the gridview user select one room (thats fine when user select save so i know which room is selected by the user). Next step is user want to select more room and available room list is long so user try to select specific building
and floor to make filter available to choose more rooms.
Once dropdownlist selected index change gridivew rebind with the filter query. Now i lost the first selection what user select and i have only current selection information.
I want to know both selection before and after filter selections.
How i can implement this? should i save the selection in viewstate before rebind the gridview if there is any selection? or is there better solution.
Thanks in advance.
Feb 19, 2016 05:22 AM|Khanna Gaurav|LINK
Make sure you bind your DropDownlist only first time when page get loaded i.e. with IsPostback as false. If you do this then you will not lose your selection.
if (IsPostBack == false)
DropdownList1.DataSource = <Some data>;
Feb 19, 2016 08:02 AM|Yohann Lu|LINK
Hi Shahid Majeed,
I suggest you can store your data in viewstate or session variable in memory. In this way, you can store the data you want at any time and you can dynamically filter out the data from viewstate or session based on dropdown selected value. I think this is
more suitable for your requirements.
The following tutorial about Cache, Session, and ViewState in the below for your reference: