Answer 2 is good.
I have a small suggestion.
is non generic type. Which means there is
no type safety
, i.e. in the above example
will both work but it will
throw error at run time
if the required type is say either
string or int
Secondly, when used with
in case of non generic types there is an
overhead of boxing and unboxing
So, it is better to use the
counter part of
explained here http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx
], by populating it with the values from the DB as already shown in Solution 2.
For the case shown in the question only one column is being used in the
in which case I think a
can be lightweight control unless there is a specific requirement to use a
is required to be used, in particular with more than one column, I think it is better to use a