locked
Filter Text starts with Numbers RRS feed

  • Question

  • User-1631883522 posted

    Hi,

    How to assign dataview rowfilter to sqldatasource filterexpression , which needs to show the list of text starts with numbers (sql query like '[0-9]%')

    Thx

    CS

    Tuesday, October 20, 2015 8:14 AM

Answers

  • User281315223 posted

    If you needed to handle this in SQL, you could just compare the first number of the string and check if it was numeric via the ISNUMERIC function :

    ISNUMERIC(SUBSTRING(LTRIM(YourColumnHere), 1, 1)) = 1 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 20, 2015 4:32 PM
  • User281315223 posted

    Thx for the Reply. We can use it LIKE '[0-9]%' in SQL. but i want to apply this in code behind dataview rowfilter as filterexpression.

    It should be mentioned that using a FilterExpression will still cause all of your data to be pulled but only the data that falls under the filter would be shown. This is just being said as if your dataset is extremely large, you might feel a bit of a performance hit as opposed to using a WHERE clause and only pulling the appropriate results.

    With regards to that, you could probably use the same basic logic as mentioned earlier :

    YourDataView.RowFilter = "ISNUMERIC(SUBSTRING(LTRIM(YourColumnHere), 1, 1)) = 1";

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 21, 2015 8:29 AM

All replies

  • User281315223 posted

    If you needed to handle this in SQL, you could just compare the first number of the string and check if it was numeric via the ISNUMERIC function :

    ISNUMERIC(SUBSTRING(LTRIM(YourColumnHere), 1, 1)) = 1 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 20, 2015 4:32 PM
  • User-1631883522 posted

    Hi Rion,

    Thx for the Reply. We can use it LIKE '[0-9]%' in SQL. but i want to apply this in code behind dataview rowfilter as filterexpression.

    ~CS

    Wednesday, October 21, 2015 3:13 AM
  • User281315223 posted

    Thx for the Reply. We can use it LIKE '[0-9]%' in SQL. but i want to apply this in code behind dataview rowfilter as filterexpression.

    It should be mentioned that using a FilterExpression will still cause all of your data to be pulled but only the data that falls under the filter would be shown. This is just being said as if your dataset is extremely large, you might feel a bit of a performance hit as opposed to using a WHERE clause and only pulling the appropriate results.

    With regards to that, you could probably use the same basic logic as mentioned earlier :

    YourDataView.RowFilter = "ISNUMERIC(SUBSTRING(LTRIM(YourColumnHere), 1, 1)) = 1";

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 21, 2015 8:29 AM