Click here to Skip to main content
15,881,669 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi. I have a DataSet which I convert to DataView in order to do filtering, distinct and sorting, however lowercase and uppercase (though same value) is not being distinct.

Here is sample value that does not make DISTINCT

AdjustmentCode | Adjustment
FLEXI-HOUSING | flexi- housing
Flexi-housing | flexi- housing
R-TRAVEL ALLOW | travel allowance
R-Travel Allow | travel allowance


Here is my code

C#
DataSet ds = new DatSet();
DataSet = dsFiltered = new DataSet();
DataTable dT = new DataTable();
ds = //put value from function
dT=ds.Tables[0];
dT.CaseSensitive=false;
DataView dView = dT.DefaultView;

dView.Sort = "Adjustment";
dT = dView.ToTable(true,"AdjustmentCode","Adjustment");
dsFiltered.Tables.Add(dT);

grid.DataSource = dsFiltered;
grid.DataBind();



I would really appreciate someone who could help me!

Thanks!
Posted
Comments
[no name] 10-Dec-15 1:36am    
What is not distinct in your example, please define.
bjay tiamsic 10-Dec-15 1:39am    
These ones(AdjustmentCode) sir. They are not being read as distinct because of lettercase

AdjustmentCode|Adjustment (description)
FLEXI-HOUSING | flexi- housing
Flexi-housing | flexi- housing
R-TRAVEL ALLOW | travel allowance
R-Travel Allow | travel allowance
bjay tiamsic 10-Dec-15 1:43am    
I should only get 2 record: FLEXI-HOUSING and R-TRAVEL ALLOW but I'm getting 4

1 solution

Set the CaseSensitive property of DataTable to True

dT.CaseSensitive=true;
 
Share this answer
 
Comments
bjay tiamsic 10-Dec-15 3:19am    
Thanks for the response. But i tried this I dont get the desired output.. Flexi-housing not being pulled up only other AdjustmentCodes

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900