Front page (source):
<dx:aspxbutton id= "Aspxbutton_select" runat= "server" text= "Query" autopostback= "false" >
<clientsideevents click= "Bt_select"/>
</dx:ASPxButton>
JS section:
function Bt_select () {
Alert (Cb_goodstype. GetValue ());
UpdateGrid ();
};
function UpdateGrid () {
var filtercondition = "1=1";
Salesman
if (Cb_buyuser. Getselectedindex ()! =-1)
Filtercondition + = "and ([sureuser] = '" + cb_buyuser. GetValue () + "')";
Supplier name
if (cb_supplers. Getselectedindex ()! =-1)
Filtercondition + = "and ([peoid]= '" + cb_supplers. GetValue () + "')";
Whether to audit
if (Cb_audflag. Getselectedindex ()! =-1)
Filtercondition + = "and ([audflag] = '" + cb_audflag. GetValue () + "')";
alert (filtercondition);
Whether to pay
if (Cb_iscollflag. Getselectedindex ()! =-1)
Filtercondition + = "and ([iscollflag] = '" + cb_iscollflag. GetValue () + "')";
Date of establishment
var mydate = new Date ();
var thedate = mydate.tolocaledatestring (); Get today's date
Get the date selected by the control and convert it
var s = aspxdateedit1.getvalue ();
var y = new Date (s). getFullYear ();
var m = new Date (s). GetMonth () + 1;
m = m < 10? (' 0 ' + m): M;
var d = new Date (s). GetDate ();
D = d < 10? (' 0 ' + D): D;
var h = new Date (s). GetHours ();
var minute = new Date (s). getminutes ();
minute = Minute < 10? (' 0 ' + minute): minute;
var dt = y + '/' + M + '/' + D + ' + H + ': ' + minute;
if (Aspxdateedit1.getvalue ())
Filtercondition + = "and [PayDate] >= '" + dt + "' and [paydate]<= '" + thedate + "'";
Filtercondition + = "and [PayDate] >= #" + dt + "# and [Paydate]<= #" + thedate + "#";
alert (filtercondition);
Aspxgridview1.applyfilter (filtercondition); Purchase goods
Aspxgridview2.applyfilter (filtercondition); Procurement services and fees
};
Note: The above query only applies to the data condition query in Aspxgridview, others do not know.
How to query on the front end with JS write condition in ASP. Without calling the stored procedure