开发工具与关键技术:下拉框绑定信息进行查询
作者:李梓良
撰写时间:2019年7月15日
一.下拉框绑定信息进行查询
要实现的功能就是选定下拉框里面的选项,然后在旁边input的标签里面就可以填上对应下拉框的条件的值。
下面这个在下拉框里有选项几个选项,选择这里面的选项,然后就可以,对应下拉框里面的条件,在input标签里面进行查询,然后就可以点击查询按钮进行查询了,我的查询的按钮就那个放大镜的按钮,我给了它按钮的代码,然后在控制器这边写方法的话,是写在查询方法的下面,然后下面我的代码的sltBianma是ID值是放在下拉框select标签里面的,然后那个txtName值就是放在查询标签button那里的。
视图层的代码:
<selectclass=“form-control” id=“sltBianma”>
<optionvalue=“1”>编码(条码)包含
商品名称包含………
<divclass=“col-sm-6”>
<inputtype=“text” class=“form-control form-control-sm"name=“txtName” id=“txtName” value=”"style=“height:34px;”>
<buttonclass=“btn” type=“button” οnclick="Subjoin(0)“style=“width:28px;background-color:#ffffff;padding-left:0px;float:right;height:27px;position:relative;top:-30px;left:-2px;”><imgsrc=”/Content/images/64.PNG"style=“height:23px;margin-top:-16px;”>
视图层方法代码:
//1.8 下拉框查询信息
function Subjoin(CommodityTypeID){
var sltBianma =$("#sltBianma").val();
var txtName =$("#txtName").val();
if (CommodityTypeID ==null)
{
CommodityTypeID = 0;
}
tabCommodity.reload({
url:“SelectCommodityManage”,
where: { sltBianma:sltBianma, txtName: txtName, CommodityTypeIDs: CommodityTypeID },
page: { curr: 1 },
});
控制器的代码:
#region 条件筛选
if (Convert.ToInt32(sltBianma) == 0)
{
if (!string.IsNullOrEmpty(txtName))
{
listVIPManage = listVIPManage.Where(m =>m.VipNumber.Contains(txtName)).ToList();
}
}
if (Convert.ToInt32(sltBianma) == 1)
{
if (!string.IsNullOrEmpty(txtName))
{
listVIPManage = listVIPManage.Where(m =>m.VipName.Contains(txtName)).ToList();
}
}
if (Convert.ToInt32(sltBianma) == 2)
{
if (!string.IsNullOrEmpty(txtName))
{
listVIPManage = listVIPManage.Where(m =>m.VipTypeName.Contains(txtName)).ToList();
}
}
if (Convert.ToInt32(sltBianma) == 3)
{
if (!string.IsNullOrEmpty(txtName))
{
listVIPManage = listVIPManage.Where(m =>m.VipContactPhone.Contains(txtName)).ToList();
}
}
if (Convert.ToInt32(sltBianma) == 4)
{
if (!string.IsNullOrEmpty(txtName))
{
listVIPManage = listVIPManage.Where(m =>m.VipSumMoney.Contains(txtName)).ToList();
}
}
#endregion