DropDownList

  • Thread starter Thread starter Rodrigo Ferreira
  • Start date Start date
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
 
Use SQlDataAdapter to execute the query and fill the dataset.Then set the
datasource of dropdownlist as dataset and bind it.
 
Rodrigo said:
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();

Well, I don't know what a "multiqual.bd" is, so I can't say what it's
devolvedataset() method returns. So, I can't say what that unknown object
isn't displaying right.

Now, assuming that it returns a Dataset, well, a Dataset can contain a
number of tables. You have to tell the DropDownList which one (via the
DataMember property) which one to use (even if there's only one)
 

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

Similar Threads


Back
Top