The common ways to manipulate Datatable

Views

DataTable.DefaultView Property

Gets a customized view of the table that may include a filtered view, or a cursor position.

  You can use the DataView constructor, or you can create a reference to the DefaultView property of the DataTable. The DataView constructor can be empty, or it can take either a DataTable as a single argument, or a DataTable along with filter criteria, sort criteria, and a row state filter. For more information about the additional arguments available for use with the DataView, see Sorting and Filtering Data.


DataView.ToTable Method (Boolean, String[])

Creates and returns a new DataTable based on rows in an existing DataView.

DataTable's Compute Methods




    object sumObject;
    sumObject = table.Compute("Sum(Total)", "EmpID = 5");

If method's filter conditional is empty, then total of rows will be calculated.

For example:

Object TotalofRows;
TotalofRows=table.Compute("Sum(ColumnName)", "");

The filter expression is empty, so total of rows will be calculated.

Share on Google Plus

About Chien

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.

0 comments:

Post a Comment