Is this a good practice and is there anything I need to look out for? I was binding repeater to an asp:SqlDataSource. Primary reason for doing this is to gain more control of the SqlCommand (e.g. CommandTimeout).
Example:
try
{
SqlDataReader MyReader = GetSomeResultsFromSqlCommand();
MyRepeater.DataSource = MyReader;
MyRepeater.DataBind();
}
catch (Exception ex)
{
throw ex;
}
finally
{
MyReader.Close();
}
This is a perfectly fine thing to do – let me offer a more succinct syntax that will provide the same results and offer the same fail-safe cleanup abilities: