Steps:
- Create Dataview Object pass DataTable object to constructer of Dataview class (Assume datatable object is Created)
- To sort Data use property called 'Sort' in Dataview object as peseduoCode shown below .
- To Filter Data use RowFilter or RowStateFilter.as peseduoCode shown below
- RowFilter is use as where clause in sql statment use all operaters use in where clause
- RowState Filter provide base on DataRow object RowState property.It is use to retrive version information with DataTable using one of the DataViewRowState enermuation
DataViewRowState Enermuation
- Added:Retervies the current DataRowVersion of DataRow Object that row state of Added
- CurrentRows:Reterive all rows that current DataRowVersion
- Deleted:Reterive the original DataRowVersion of DataRow object that have a RowState of deleted.
- ModifiedCurrent:Reterives the Current DataRow Version of DateRow object that have RowState of modified
- ModifiedOriginal:Reterives the Original DataRow Version of DateRow object that have RowState of modified
- None:Clears Row state filter property
- OriginalRows:Reterive the DataRow object that have original DataRowVersion.
- Unchanged: Reterive DataRow object that have row state of unchanged
PseduoCode
////Dataview Sort
DataView view = new DataView("datableobject"); view.Sort= "columname1 ASC , columnname2 DESC"; ///Binding datasource gird; gridobject.DataSource=view; gridobject.DataBind();
////////////////// ////Dataview RowFilter
view.RowFilter ="columname1 like '%A' and columname2 < 26 "; //Do Some Thing
////////////////////// ////DateView RowState property
view.RowStateFilter = DataRowState.Added //DataRowState.Enumerationnames //Do Some Thing
DataView view = new DataView("datableobject"); view.Sort= "columname1 ASC , columnname2 DESC"; ///Binding datasource gird; gridobject.DataSource=view; gridobject.DataBind();
////////////////// ////Dataview RowFilter
view.RowFilter ="columname1 like '%A' and columname2 < 26 "; //Do Some Thing
////////////////////// ////DateView RowState property
view.RowStateFilter = DataRowState.Added //DataRowState.Enumerationnames //Do Some Thing