Notes (DataTable Filter, time format, JS verification number, JS summation)

Source: Internet
Author: User

(1) Screening data in a DataTable:

DataTable dt=new DataTable ();

DataView Dv=dt. DefaultView;

Dv. Rowfilter=string. Format ("Name={0} and Namet={1}", Value,valuet);

DataTable NEWDT=DV. ToTable ();

(2) When the query is made according to the time period condition

Data SQL statements in the conditional: SJ between SJ1 and Sj2

To format the obtained string string when fetching data in the background:

String sj1 = This.sj.Text.Trim () = = "" ": Convert.todatetime (This.sj.Text.Trim ()). ToString ("D-m month-yyyy");

(3) JS verification number

JS Method:

function Valnum (ID) {

var val = document.getElementById (id). value; Values for each part

var mod =/^[+-]?/d+ (/./d+)? $/; Verifying number Validity

if (Val!= "") {

if (!mod.test (val)) {

document.getElementById (id + ' Info '). Style.display = "block";

return false;

} else {

document.getElementById (id + ' Info '). Style.display = "None";

}

}

else {

document.getElementById (id + ' Info '). Style.display = "None";

}

Return

}

After the page tag, add: <span id= "Bysrinfo" style= color:red; Display:none "> Please enter a number </span> as a tip panel for information

(4) JS sum

The obtained value is treated directly with + +, and the program is connected as a string.

function Valtolnum (ID) {

var val = document.getElementById (id). value; Values for each part

var valvalue = document.getElementById ("Bzhj"). Value; Value of the total value control

var mod =/^[+-]?/d+ (/./d+)? $/; Verifying number Validity

if (Val!= "") {if (!mod.test (val)) {...}   ...} Verifying information

Sum first *1 The value you get, so you can treat it as a number

Valvalue = Valvalue * 1 + val * 1;

document.getElementById ("Bzhj"). Value = Valvalue;

Return

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.