protected void Page_Load(object sender, System.EventArgs e)
{
Data.DataSet DataSet1 = new Data.DataSet();
DataSet1.ReadXml("C:\\Temp\\DataTable1.xml");
Data.DataTable DataTable1 = DataSet1.Tables(0);
Data.DataTable UniqueValuesInDataTable = GetUniqueTableValues(DataTable1);
}
protected Data.DataTable GetUniqueTableValues(Data.DataTable ValuesDataTable)
{
Data.DataTable ReturnValuesDataTable = null;
Data.DataTable UniqueColumnValuesDataTable = new Data.DataTable();
UniqueColumnValuesDataTable.Columns.Add("UniqueValues");
foreach (Data.DataColumn ValuesDataColumn in ValuesDataTable.Columns) {
Data.DataTable UniqueValuesInThisColumnDataTable = ValuesDataTable.DefaultView.ToTable(true, ValuesDataColumn.ColumnName);
UniqueValuesInThisColumnDataTable.Columns(0).ColumnName = "UniqueValues";
foreach (Data.DataRow UniqueValuesDataRow in UniqueValuesInThisColumnDataTable.Rows) {
UniqueColumnValuesDataTable.ImportRow(UniqueValuesDataRow);
}
}
UniqueColumnValuesDataTable.DefaultView.Sort = "UniqueValues";
ReturnValuesDataTable = UniqueColumnValuesDataTable.DefaultView.ToTable(true, "UniqueValues");
return ReturnValuesDataTable;
}
Get unique values from entire table.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment