下拉列表事件MVC 5

时间:2018-06-07 14:31:23

标签: c# asp.net-mvc razor

我有一个下拉列表,其中包含从数据库绑定的产品列表。我想加载选定的产品数据。

这是我在视图中的代码

popupBinding = PasswordPopupBinding.inflate(LayoutInflater.from(getContext()));
View suggestionView = popupBinding.getRoot();
PopupWindow suggestionPopup = new PopupWindow();
suggestionPopup.setContentView(suggestionView);
binding.passwordTextView.setSuggestionPopup(suggestionPopup);

我使用java脚本代码发送选择产品ID然后获取它的数据

    txt.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, Collections.emptySet());
    txt.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent event) {
        if (event.getKeyChar() == KeyEvent.VK_TAB) {

        }
       }
    });

此代码发送所选索引的问题不是所选产品的问题,它也会将id作为字符串发送,因此它永远不会达到我的条件 在成功的情况下,我应该写的最后一件事

1 个答案:

答案 0 :(得分:0)

它通过

解决了
var ProductID = this.value;