--定义字段
String mCostStartDate = RequestHelper.GetQueryString("CostStartDate"); String mCostEndDate = RequestHelper.GetQueryString("CostEndDate");--带上字段
mDicInputParam.Add(new DbParam("CostStartDate", mCostStartDate)); mDicInputParam.Add(new DbParam("CostEndDate", mCostEndDate));--时间选择不显示缺少的JS引用 <%=HtmlControlHelper.GetRelJs(ResolveUrl("~/Res/Datepicker/WdatePicker.js"))%>--导出时的参数不能少 $('#btnExport').click(function () { var mCostStartDate = document.getElementById("CostStartDate").value; var mCostEndDate = document.getElementById("CostEndDate").value; var sUrl = "<%=RequestHelper.GetPageName()%>?IsExport=1&CostStartDate="+mCostStartDate+"&CostEndDate="+mCostEndDate; window.open(sUrl); return false; });--查询参数要正确$('#btnQuery').click(function () { var mCostStartDate = $('#CostStartDate').val(); var mCostEndDate = $('#CostEndDate').val(); var sUrl = "<%=RequestHelper.GetPageName() %>?CostStartDate=" + mCostStartDate + "&CostEndDate=" + mCostEndDate; location.href = sUrl; return false; });--选择框
<table> <tr> <td style="padding-left: 4px; width: 80px;"> 开始时间: </td> <td> <%=HtmlControlHelper.GetDateTime("CostStartDate", mCostStartDate, "", "")%> </td> <td> 结束时间: </td> <td> <%=HtmlControlHelper.GetDateTime("CostEndDate", mCostEndDate, "", "")%> </td> <td> <%=HtmlControlHelper.GetHrefInfo("btnQuery", "查询", "Javascript:void(0);", "toolMenu", "")%> </td> </tr> </table>--存储过程条件要正确,4种情况:前为空,后为空,两者都为空,两者都不为空
WHERE (Asset_Contract_ChargePlan.CostStartDate between @pi_CostStartDate and @pi_CostEndDate or @pi_CostStartDate='' or @pi_CostEndDate='')