By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,925 Members | 732 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,925 IT Pros & Developers. It's quick & easy.

Query on DataView.Sort Property

P: n/a
Hi,

I am using the DataView.Sort Property (on a DataView column) to sort
the View based on some condition.

Now the column that I need to sort contains characters and HTML code
that should not be considered when sorting is done. (e.g. -> <B>,
<FONT ...>, " , ' , etc...).
To illustarte:
Example 1
<B>This is a...</B> should be sorted as -> This is a... (disregard the
<B>)

Example 2
"Hello friends..." should be sorted as -> Hello friends... (disregard
the ")

The DataColumn.Expression Property does not support "PATINDEX". It
supports SUBSTRING & LEN though.

And I do not want to do this sorting in the SQL SP. Any pointers will
be appreciated.

Thanks for your time.

Cheerz,
Denzil
Jul 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi,

Off the top of my head, maybe a solution would be to add a extra column to
the dataset (not the database) and put the clean text in the column. After
calling Fill() you can add the column and run through the records cleaning
the data ie. remove unwanted tags and punctuation etc. and putting the clean
text into the new column. Then you can use this 'cleaned' column as the sort
column.

Thinking about this solution I got another idea for populating the cleaned
column, I am sure it will *not* give great performance, but the code is
simpler. (And interesting, I was not sure it would work so I tested it).

Fill the DataSet using FillSchema( ds, SchemaType.Mapped ), then add the
column to the DataTable and add an event handler for the RowChanged event.
Then call Fill to populate the DataSet. As the DataTable in the DataSet is
populated the RowChanged events fires for each new row added by the Fill
procedure, if the event action is DataRowAction.Add clean the text of the
source column and set the value of the 'cleaned' column to the cleaned text.
Watch out, the event will fire twice because of the changing of the column
value so it is important to check the action.

Hope that helps

Chris Taylor

"Denzil" <de***********@lycos.com> wrote in message
news:29**************************@posting.google.c om...
Hi,

I am using the DataView.Sort Property (on a DataView column) to sort
the View based on some condition.

Now the column that I need to sort contains characters and HTML code
that should not be considered when sorting is done. (e.g. -> <B>,
<FONT ...>, " , ' , etc...).
To illustarte:
Example 1
<B>This is a...</B> should be sorted as -> This is a... (disregard the
<B>)

Example 2
"Hello friends..." should be sorted as -> Hello friends... (disregard
the ")

The DataColumn.Expression Property does not support "PATINDEX". It
supports SUBSTRING & LEN though.

And I do not want to do this sorting in the SQL SP. Any pointers will
be appreciated.

Thanks for your time.

Cheerz,
Denzil

Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.