If the data item is an entity (wrapped in an EntityDataSourceWrapper) you can use the method described here.

If not (and you are using a custom select statement), you have two choices: