some code tips for may 1

<%#DataBinder.Eval(Container.DataItem, >>
"stringDate", "{0:MMMM d, yyyy}") %>

will display as: May 1, 2007. more details and specifics can be found on

you can also call a function on a DataBinder.Eval item, such as:
<%#TruncDescrip((string)DataBinder.Eval >>
(Container.DataItem, "stringDescription")) %>

with the underlying function in the code behind looking like:

protected string TruncDescrip(string descrip)
string shortDescrip = descrip.Substring(0, 100);
shortDescrip += "&#8230";

return shortDescrip;

Also, some sweet one-line code action when using the Microsoft Enterprise Library. Create a dataset, connect to the database, and fill the dataset – all at once.

DataSet dsNewsItems = DatabaseFactory.CreateDatabase("DatabaseName"). >> ExecuteDataSet(CommandType.StoredProcedure, "uspDoSomethingCool");

line breaks (inserted for readability) denoted by >>.

maybe not all best practices, and I did read the problems surrounding the late binding of the some of the above code, but .NET 2.0 is still new to me, so I’ll stick with these for now – and it’s not for a big production system anyway.

one other note that I found today – ctrl + shift + esc – will open up task manager. pretty handy.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s