简体   繁体   English

关闭模态窗口后如何在父页面上更新下拉列表

[英]How to update a dropdown list on parent page after closing modal window

Okay, so I have an ASP.NET WebForms page with C# code behind. 好的,所以我有一个ASP.NET WebForms页面,后面带有C#代码。 I have a dropdown list bound to a data table in SQL. 我有一个绑定到SQL中的数据表的下拉列表。 I am adding a maintenance screen (modal) for users to manage the data in the table/dropdown (add/inactivate records). 我正在添加一个维护屏幕(模式),供用户管理表/下拉列表中的数据(添加/停用记录)。 The user clicks a '+' button next to the dropdown list, the modal comes up, they add or remove a record, and then close the modal. 用户单击下拉列表旁边的“ +”按钮,出现模式,他们添加或删除记录,然后关闭模式。 Upon closing (in the 'Close:' property) I'd like to have the dropdown list on the parent page rebind to the updated table data, preferrably without posting back. 关闭后(在“ Close:”属性中),我希望父页面上的下拉列表重新绑定到更新的表数据,最好不回发。

I'm having a tough time doing this, anyone have any suggestions? 我现在很难过,有人有什么建议吗?

Code behind to bind drop down to original data on parent Page_Load: 后面的代码将下拉列表绑定到父Page_Load上的原始数据:

var fundingTypes = client.GetFundingTypeAll();
var onlyActiveFundingTypes = fundingTypes.FindAll(x => x.IsActive == true);
EncryptionHelper.EncryptProperties(onlyActiveFundingTypes);
ddlFundingType.DataSource = onlyActiveFundingTypes;
ddlFundingType.DataValueField = "Id_X";
ddlFundingType.DataTextField = "Name";
ddlFundingType.DataBind();

Could this be done using a WebMethod call to the code behind to do the rebind? 可以使用WebMethod调用后面的代码来进行重新绑定吗?

Thank you! 谢谢!

Either use an UpdatePanel that can cause a partial post back or use AJAX calls that can bind the new data on your page (via templating). 使用可能导致部分回发的UpdatePanel或使用可以绑定页面上新数据的AJAX调用(通过模板)。

I am guessing option #2 (AJAX with templating) will not be a viable solution for you as it would involve re-working the approach to your UI. 我猜选项2(带有模板的AJAX)对您来说不是一个可行的解决方案,因为它将涉及重新设计UI的方法。

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

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