English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I've been using someone else's code, which does this all by hand. Works great, but isn't there an easier way to bind data to a DDL control? I'd like to start with a new C# web app, and add a DDL, then bind data using the properties of the drop list. Looks like everything is OK, but the list is always empty when I test it. I add sqlDataAdapter, sqlConnection1, and finally a dataset. Am I just missing the final trigger or something?

2006-07-19 04:34:12 · 1 answers · asked by sideshot72 3 in Computers & Internet Programming & Design

Yes. I know I can see the data, because earlier I was unable to preview it and see it. However, I can see it from the IDE. I do everything you list in the the properties for the DDL, except the DataBind() call, which I put into the C# file. I break on it, and I see it get called, but no data in the DDL. I'll check the dataset. Maybe I am not coding population of the dataset?

2006-07-19 05:05:32 · update #1

1 answers

First off, did you confirmat that your DataSet has the data in it?

Assuming your Drop down list is called "lstPeople" and your DataSet is called "dsPeople":

//Set the displayed text for the list
this.lstPeople.DataTextField = "FirstName";

//Set the value field for the list
this.lstPeople.DataValueField = "PersonID";

//Set the DataSource
this.lstPeople.DataSource = dsPeople;

//Finally, do your DataBind
this.lstPeople.DataBind();

2006-07-19 04:57:57 · answer #1 · answered by Kryzchek 4 · 0 0

fedest.com, questions and answers