DataTable dtddlHotel=GetDataFromData();
DataTable distinctTable = dtddlHotel.DefaultView.ToTable( /*distinct*/ true);
--------------------------------------
Or
------------
Example
----------
Table Emp Has One column Year and having Data
------------------
Year
------
2014
2015
2016
----------------------
DataTable dt = new DataTable();
dt=getData("Select Year From emp");
DataView dtview = new DataView(dt);
dtview.Sort = "Year DESC";
dt = dtview.ToTable();
------------------------------------
Now In dt
contain
Result
---------------------
Year
--------
2016
2015
2014
----------------------------------------
For Asending
-------------------
DataTable dt = new DataTable();
dt=getData("Select Year From emp");
DataView dtview = new DataView(dt);
dtview.Sort = "Year ASC";
dt = dtview.ToTable();
DataTable distinctTable = dtddlHotel.DefaultView.ToTable( /*distinct*/ true);
--------------------------------------
Or
------------
Example
----------
Table Emp Has One column Year and having Data
------------------
Year
------
2014
2015
2016
----------------------
DataTable dt = new DataTable();
dt=getData("Select Year From emp");
DataView dtview = new DataView(dt);
dtview.Sort = "Year DESC";
dt = dtview.ToTable();
------------------------------------
Now In dt
contain
Result
---------------------
Year
--------
2016
2015
2014
----------------------------------------
For Asending
-------------------
DataTable dt = new DataTable();
dt=getData("Select Year From emp");
DataView dtview = new DataView(dt);
dtview.Sort = "Year ASC";
dt = dtview.ToTable();
No comments:
Post a Comment