DropDownList

R

Rodrigo Ferreira

Hello,

How can i fill a dropdownlist with data returned by the database?

My code is:

string strsql = "SELECT designacao FROM categorias";
multiqual.bd db1 = new multiqual.bd();
ddlCategoria.DataSource = db1.devolvedataset(strsql);
ddlCategoria.DataBind();


Greetings,
Rodrigo Ferreira
 
K

Karl Seguin

You must specify the DataTextField and DataVlaueField

ddlCategoria.DataSource = db1.devolvedataset(strsql);
ddlCategoria.DataValueField = "designacao";
ddlCategoria.DataTextField = "designacao";
ddlCategoria.DataBind();

Karl
 
R

Rodrigo Ferreira

Ok! Thanks!

Karl Seguin said:
You must specify the DataTextField and DataVlaueField

ddlCategoria.DataSource = db1.devolvedataset(strsql);
ddlCategoria.DataValueField = "designacao";
ddlCategoria.DataTextField = "designacao";
ddlCategoria.DataBind();

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,134
Latest member
Lou6777736
Top