Hi Bonnie
I have tried your suggestion, it didn't crash but it didn't sort the column correctly either.
I have also tried.
this.AnimalsDt.DefaultView.Sort = "EarTag.Substr(1,8).Trim(), EarTag.Substr(EarTag.length-5).Trim()";
this.AnimalsDt.DefaultView.Sort = "OT.Substr(1,8) + OT.Substr(OT.length-5)";
Theses didn’t work either.
The data in the column varies in length.
Do you have any other ideas on sorting the column?
Thanks.
John
>Well, John, I know you can do this:
>
>this.AnimalsDt.DefaultView.Sort = "EarTag, AnotherColumn, Etc" ;
>
>but, whether or not you can do this;
>
>this.AnimalsDt.DefaultView.Sort = "EarTag.Substr(1,8), Eartag.Substr(Eartag.length-5)";
>
>I'm not sure. Try it and see if it works.
>
>~~Bonnie
>
>>I need to sort a datatable / view on an expression.
>>
>>In VFP you can use INDEX ON LEFT(ALLTRIM(Eartag),8)+RIGHT(ALLTRIM(Eartag),5)
>>
>>I can sort the column using the following code.
>>
>>
>>this.AnimalsDt.DefaultView.Sort = "EarTag ASC" ;
>>
>>
>>How sort it using an expression using C#.
>>
>>Thanks
>>
>>John