且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何保留分页中的下拉列表值???

更新时间:2023-02-24 22:15:25

您必须将选定的值保持在某个位置,并再次显示选定的项目.
看看下面的文章.它会帮你
维护GridView内部不同页面中选定复选框的状态
You have to maintain the selected value somewhere and show the selected item once again loaded.
Have a look to the following article. It''ll help you
Maintaining States of Selected CheckBoxes in Different Pages inside the GridView


我在ddl中有一些数据.我更改了ddl中的数据,然后转到第二页.如果我从第二页回到第一页,则它不会保留更改后的值.它正在获取默认值
确保将下拉填充代码放在属性IsPostback 中.确保它不会在每次页面回发时都重新填充.
I have some data in ddl. I changed data in ddl and going to second page. If I come back to first page from 2nd page, it is not retaining changed values. It is getting default values
Sure you put the dropdown populating code in page IsPostback property. Make sure it is not getting repopulated on every page postback.


这有点棘手的逻辑.

每次从一页移动到另一页时,数据都会重新加载.

选项1

将每个页面导航上的DDL选定的值数据保存到DB中.
在绑定时,您将检查保存的值并更改DDL的选定索引.

选项2

将所选值存储在某个临时位置并重复使用(但是您可以保存房屋值吗?如果还有更多页面?)
This is bit tricky logic.

Every time you move from 1 page to other, the data will get loaded freshly.

Option 1

Save the selected value data of DDL on every page navigation in to the DB.
Onbind you check the saved value and change the selected index of the DDL.

Option 2

Store the selected value in some temporary place and re-use(But home values you can save? If the pages more?)
Please ref Brij Ans