December 22, 2003

Dynamic Templates for the Repeater, DataList and DataGrid Controls

ost of the time, when you add a Repeater, DataList or DataGrid control on the page, you hardcode their templates: you know the data you want to show, and to do this you declare Literal, Label, CheckBox and any other type of control with bindable properties, or simply add static

Parsing strings with a custom pattern into a Date variable

The Parse static method of the Date type does a good job in parsing an input string and returning a Date instance. It recognizes and accepts the commonly used separators for the date part, such as / or -, and : for the time. It also has overloaded versions that

Dragging & dropping files on a form

Most document-based applications typically allow to open a document file in two ways: with the Open File menu command / toolbar button, or by dragging and dropping the file from Windows Explorer to the application’s window. This works with MS Word, Winzip and many other applications. Implementing the same feature

Retrieving the ID of the last inserted record

When you add a new record to a SQL Server table that has an identity column, you usually want to read back the auto-generated ID, for example to use it as a foreign key in another table. If you use stored procedures this is easy to do: just use an

Splitting a string into substrings when the separator is not a single char

The String type has an instance method, Split, that splits the instance string into an array of substrings. The problem with this method is that it can only use single characters as a separator, not a string. What if you separator is “{tab}—{tab}” or something else? It turns out that