Saturday, March 24, 2012

Populate dropdown list

How can I populate a dropdownlist with data from a database using
Microsoft.ApplicationBlocks.Data ?
ThanksUse one of the SqlHelper methods. For instance, SqlHelper.ExecuteDataSet(.
.. .), and then just map the DataSource = returnedDataSet.Tables[0];, and
then you can set which field for the text and the value. All the
applications blocks do is encapsulate the ado.net call, so instead of
creating your connection object, then command object and executing the
command to return something, you call a static method of SqlHelper passing
in a connection string or connection or transaction object, the query or
stored procedure to run, some other potential options, and you'll get a
result back.

I have wrapped the Data Access application block in my own class that, upon
instantiation, creates a connection from the connection string stored in my
config file, and then it's ready to exectue anything. On Dispose() of my
object, I close my connection.

Best regards,
Jeffrey Palermo

"Mark Goldin" <markgoldin@.comcast.net> wrote in message
news:ug6v1VccEHA.1764@.TK2MSFTNGP10.phx.gbl...
> How can I populate a dropdownlist with data from a database using
> Microsoft.ApplicationBlocks.Data ?
> Thanks
>

0 comments:

Post a Comment