如何根据下拉列表选择从数据库中检索数据? [英] How can I retrieve data from a database based on dropdown list selection?

查看:95
本文介绍了如何根据下拉列表选择从数据库中检索数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个下拉列表,其中包含以下选项:

已批准

已拒登

未读

阅读



将根据管理员的选择(基于事件)从数据库中搜索和检索数据,这意味着每次更改选择时,结果都会显示根据标准设置刷新。我怎样才能实现这一目标?

I have a drop-down list, with the following options:
Approved
Disapproved
Unread
Read

Data will be searched and retrieved from a database based on the selection of the admin, event-based, meaning every time the selection is changed, the results shown are refreshed according to the criteria set. How can I achieve this?

推荐答案

在下拉列表更改事件中,您可以将所选值作为 this.value 。然后将该数据传递到服务器端,以使用jQuery Ajax检索与其相关的适当数据。有许多关于在CP上使用jQuery实现这一点的好文章。



请在这里参考其中一些:

使用ASP.NET MVC4中的部分视图和jQueryUI进行CRUD操作 - 第2部分 [ ^ ]

使用ASP.NET Web API执行CRUD操作 - 第2部分 [ ^ ]



我希望这会帮助你入门。如果你在某个地方陷入困境,那么请在工作时发布一个新问题以及无法正常工作的代码。
On dropdown change event you can get the selected value as this.value. Then pass that data to server side to retrieve the appropriate data related to it using jQuery Ajax. There are many good articles on implementing this using jQuery on CP.

Please refer to some of them here:
CRUD Operations using Partial View and jQueryUI in ASP.NET MVC4 - Part 2[^]
Performing CRUD operations using ASP.NET Web API - Part 2[^]

I hope this would help you getting started. If you get stuck in somewhere, then please post a new question along with the code which was not working properly for you while working on it.


这是很多编码。你需要自己解决。



但这里有一个提示:

你可以做Jquery AJAX [ ^ ]根据您的下拉选择调用服务器。

您可以在
That's a lot of coding. That you need to figure out on your own.

But here's a tip :
You can make Jquery AJAX[^] call to the server based on your dropdown selection.
And you can refresh your set of collection in success function of the

<的成功函数中刷新您的集合集br />


.Ajax({...})



-KR
.Ajax({...}).

-KR


这篇关于如何根据下拉列表选择从数据库中检索数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆