如何在下拉列表中保留数据? [英] how to make retain data in dropdownlist?
问题描述
我有一个包含下拉列表的表单,其中有4个值从数据库中获取并有一个按钮。
现在页面加载我已经编写了用于在下拉列表中获取数据的编码,我得到了这个和我从中选择一个值,但是当我点击按钮上的附加功能时,下拉列表也会刷新(我选择的值将被下拉列表中的第一个值替换...我尝试了按钮上的自动回复,也是下拉列表中的但是已经没有影响
。我可以停止这个
请告诉
问候
< blockquote>
我猜你在所有页面加载中加载你的下拉列表,无论它是否回传。
你可以加载你的下拉列表,只有它的初始页面加载而不是回发。
喜欢,
if (!IsPostBack)
{
// 那么你的代码在这里
}
希望这个帮助
I have one form containing dropdownlist with 4 values in it fetching from database and have one button.
now on page load i have written coding for fetching data in dropdownlist and i am getting that and i select one value from it but when i click on button for "additional functionality" on it then dropdownlist also get refreshed(the value i selected is replaced by first value in dropdownlist...i tried of autopostback on button and too on dropdownlist but had no affect
.how can i stop this
pls tell
regards
Hi,
I guess you are loading your dropdown in all the pageloads, irrespective of whether its a post back or not.
You can load your dropdown only if its a initial page load and not a post back.
like,
if(!IsPostBack) { //then your code here }
Hope this helps.
这篇关于如何在下拉列表中保留数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!