简体   繁体   English

在ASP.NET的页面重新加载中,下拉列表值未更改

[英]Dropdown value not changing on page reload in asp.net

I am using DropdownList in my aspx page. 我在我的aspx页面中使用了DropdownList。

When I bind the first time it shows the correct selected value, but when I change the value through another aspx page and refresh this parent page, the value does not change in the drop-down, it still remains same. 当我第一次绑定时,它显示正确的选定值,但是当我通过另一个aspx页面更改该值并刷新此父页面时,该值在下拉列表中没有变化,它仍然保持不变。

dropdownList1.DataSource = dt;  
dropdownList1.DataBind();
dropdownList1.ClearSelection();
dropdownList1.Items.FindByText("some value").Selected = true;

On re-loading the aspx page, although the selected value of dropdownlist has changed but it dos not get affected in the dropdown. 在重新加载aspx页面时,虽然dropdownlist的选定值已更改,但在下拉列表中不会受到影响。 What could be the solution to this problem. 有什么办法可以解决这个问题。

Any help is appreciable ... 任何帮助都是可观的...

尝试如下设置选定的值...

ddl.SelectedValue = ddl.Items.FindByText(your text).Value;

On close of pop-up window, we need to execute the following javascript function as follows... 在弹出窗口关闭时,我们需要执行以下javascript函数,如下所示...

function closePopUp() { window.opener.ReloadParentPage(); 函数closePopUp(){window.opener.ReloadParentPage(); } }

function ReloadParentPage() { popupWindow.close(); 函数ReloadParentPage(){popupWindow.close(); var path = window.location.href.split("#"); var path = window.location.href.split(“#”); window.location.href = path[0]; window.location.href = path [0]; } }

If you are using the relative path try setting window.location.pathname, or set window.location.href to the full path and split is used to avoid # in URL. 如果您使用相对路径,请尝试将window.location.pathname设置为完整路径,或将window.location.href设置为完整路径,并使用split来避免URL中的#。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM