How to flexibly use the select method in datatable

Source: Internet
Author: User

 

In operationDatatableYou may also encounter a common problem.DatatableSome rows in modify the status,
I mean manually explicitly modified, for exampleCode:

//Adds a Status column to the new table to indicate whether the table has been accessed.

Datatable temptable = dtdatatable [I]. Copy ();

Temptable. Columns. Add ("Visited",Typeof(Bool));

Foreach(Datarow temprowInTemptable. Rows)

{

Temprow ["Visited"] =False;

}

 

//Then, some rows are operated and the status is modified.

Foreach(Datarow adatarowInTemptable. Rows)

{

If(Adatarow ["Stepno"]. Tostring ())

{

Adatarow ["Totalprice"] = 0;

Adatarow ["Visited"] =True;

}

}

Then Temptable There will be some Row Column Visited = false . How to find these columns?

 

Of course it corresponds to the question in this article

Datarow [] unvisitedrows = temptable. Select ("Visited = false");

apparently, it returns a datarow , next, how to operate on each row in the array, needless to say. One thing to note is that my
previous blog

Dataset, datatable. datarowCopy Method--Solution: This row already belongs to another table.

 

In addition,PublicDatarow[] Select ( String Filterexpression)

Filterexpression   This parameter can also be used   And, or  And other operators, such:  Filterexpression 
="Id = 'D' or stepnt <> ''" .

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.