复选框过滤查询 [英] Check Box Filter Query

查看:86
本文介绍了复选框过滤查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个ASP.net页,其中包含6个复选框.
用户有时可能会选中一个框,两个框...最多6个框.

当用户选中多个框时,我们会组合多个框

每当做出这样的选择时,我都需要从sql数据库中检索数据,为此,我需要编写动态查询,其中参数不断变化

如果我们尝试使用传统方法,则我需要编写的查询数量多达720个

还有什么算法可以使我的工作更简单

可以将此要求与手机购买网站进行比较.
这些网站为您提供了选择手机功能的选项
像是蓝牙IR,收音机gprs等

您选择了IR n radio,则无论是否存在gprs和蓝牙,所有具有IR和广播功能的电话都将出现.

Hi,

I have a ASP.net page, which contains 6 check boxes.
The user might sometimes check one box, 2boxes... upto 6 boxes.

when user checks more than one box, we have combinations of boxes

When ever such selections are made, i need to retrieve data from sql database, for this i need to write dynamic query, where the paramters keep changing

If we try in conventional methods, the number of queries tht i need to write reaches as much as 720

So is there any algorithm which makes my work simpler

This requirement can be compared to a mobile phone buying site.
where those sites give u options to choose the features of a phone
like bluetooth IR, radio gprs etc

you choose IR n radio, and all the phone having IR and radio will come irrespective of the presence of gprs and blutooth.

推荐答案



您可以使用 CheckBoxList 控件,该控件可以具有多个复选框

当单击按钮
时,请考虑控件CheckBoxList的ID为 C 取得搜索结果的功能被调用,您编写以下条件


Hi

You can use CheckBoxList control, which can have multiple check boxes

Consider control CheckBoxList has id C when you click on button
funtion to get the serach result gets called in that funstion you write the below condition


for(int i=0; i< c.Items.Count;i++)
{
  if(c.Items[i].Selected)
    {
        // get the selected checkbox value using c.Items[i].Text
         
    }
}



编写SQL Select查询以通过传递复选框选择的值来获取数据,或使用存储过程来获取数据



Write the SQL Select query to fetch the data by passing the checkbox selected values or use stored procedure to fetch data


这篇关于复选框过滤查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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