Archive for January, 2007

Validation Expressions – Postal Codes – US and Canada

Here’s the regular expression for US & Canada Postal Codes:
^(\d{5}(( |-)\d{4})?)|([A-Za-z]\d[A-Za-z]( |-)\d[A-Za-z]\d)$

Stipping Invalid Characters from a String

First, it’s called “stripping!” Second, to strip these characters from a string, you must use the Regex.Replace method. — as denoted by microsoft here.

using System.Text.RegularExpressions

Regex.Replace(strInput, @”[^\w\.@-]”, “”);

This will strinp all invalid characters EXCEPT the period, @, and hyphen.

Sorting GridView in Imar.Spaanjaars article

Articls are posted here: http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=416

For Sorting:

1. Create an overload of GetList that accepts the SortExpression as a String.

2. Change the ODS declaration so it contains a parameter for this new sortExpression:

[SelectParameters]
[asp:Parameter Name=”sortExpression” Type=”String” /]
[/SelectParameters]

3. Set the SortParameterName attribute of the ODS:

SortParameterName=”sortExpression”

4. Enable sorting on the GridView.