我应该在客户端查询数据库还是后面的代码? [英] Should I query a DB on the client side or code behind?

查看:74
本文介绍了我应该在客户端查询数据库还是后面的代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在来回询问是否要在数据库中查询客户端数据或背后的代码,我想知道是否有人了解有关最佳方法和示例的信息.

这就是我想要做的:

我有一个可供用户选择的列和2个下拉列表的列表框.

我希望从列表框中选择的值填充到第一个下拉列表中.

用户选择他想要的列,然后第二个下拉列表(我正在尝试进行多选下拉列表,但还没有找到一个我可以使用的很好的示例),将基于以下内容的表中的值填充到该列表中:第一个下拉选择.

所以,

列表框选择的值->下拉菜单1

Dropdown1选定的值成为查询数据库的参数,以返回第一个下拉列表的值.

----
第二名:

还有另一组下拉列表,其中填充了相同的列表框值.但是,当用户在第一个下拉列表中选择一个值时,我希望它在第二个下拉列表中消失,以便他们看不到它或选择它为2ce.

在这里,我认为客户端查询比为每个下拉列表向服务器调用要好.

我目前有客户端脚本,将选定的列表框值填充到下拉框中,但是恐怕在进行回发时,除非将它们放入自己的更新面板中,否则它们会消失吗?

这是混乱的还是有意义的?另外,我没有使用AJAX,但是在编写此文件时,这也可能是一个不错的选择.我已经很长时间没有做过ASP工作了,我很生疏,所以当我尝试使用它时,我遇到了问题.

如果我可以在没有AJAX的情况下获得建议,那将有所帮助.

I''ve been going back and forth on whether to query a database for data on the client side or the code behind and I''m wondering if anyone has any info on the best way and possibly examples.

This is what I''m wanting to do:

I have a list box of columns that the user can select and 2 dropdown objects.

I want the selected values from the list box to populate in 1st dropdown.

The user selects the column he wants, and the second dropdown (which I''m trying to make a multi-select dropdown but haven''t found a good example that I can get working) to populate with values from a table based on the 1st dropdown selection.

So,

Listbox selected values --> Dropdown1

Dropdown1 selected value becomes parameter for a query to the database to return values for the 1st dropdown.

----
2nd:

There is another set of dropdowns that are populated with the same listbox values. but, when the user selects a value in the 1st dropdown, I want it to disappear in the 2nd set of dropdowns so they can''t see it or choose it 2ce.

This is where I thought client-side querying would be better than making calls back to the server for each set of dropdowns.

I currently have client-side scripting populating the selected listbox values into the dropdown boxes but I''m afraid when I do a post-back, they will disappear unless I put them into their own update panel?

Is this confusing or make sense? Also, I''m not using AJAX but as I''m writing this, that might be a good alternative too. I haven''t done ASP work in a long time and I''m rusty so when I tried to work with it, I had problems.

If I can get suggestions without AJAX, that would be helpful.

推荐答案

服务器端.您的目标应该是减少客户端和服务器之间的流量.
Server side. Your aim should be to reduce the traffic between the client and the server.


在这种情况下,我还建议使用服务器端编码. ASP.NET中Ajax的实现非常简单
ajax.net-tutorials.com
i also recommend server side coding on this scenario. implementation of Ajax is very very simple in ASP.NET
ajax.net-tutorials.com


这篇关于我应该在客户端查询数据库还是后面的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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