Start New Discussion within our Software Development Community

Hi everyone! I haven't seen this question here, so I'll give it a try.

I'm from a country where some words have accents, like MarĂ­a.

I have all this words in a database and I would like to use the Select function from a DataTable but ignoring accents in the database.

I know this may be not possible; if it's not, it really should be implemented. Thanks in advance!
This is my current code:

dataTable.DefaultView.RowFilter = string.IsNullOrEmpty(text) ? string.Empty : string.Format("{0} LIKE '%{1}%'", field, text);

I believe you are going to have to normalize and strip the diacritics from the string first.


You could add new column to your datatable with the processed string and then do the row filter against that processed string.

Or you could use LINQ to create a list of datarows and use that presumably as a datagridview.DataSource.

Something like this:

List<DataRow> rows = (from row in dt.AsEnumerable() 
                      where System.Text.RegularExpressions.Regex.IsMatch(RemoveDiacritics(((DataRow) row)[0].ToString()), "Maria*") 
                      select row).ToList();
This question has already been answered. Start a new discussion instead.