DropDownList and DataSet. Where is my error?

  • Thread starter Thread starter Emanuele
  • Start date Start date
E

Emanuele

Hi People, I want populate one DropDownList with a DataSet.
I've got one problem when I pass the data and text value. My code
(propabily wrong)
pass always the first value of my droplist.

DataSet dst = new DataSet();


dst = myobject.GetDataSet();


droplist.DataSource = dst.Tables[0];
droplist.DataTextField =
dst.Tables[0].Columns["TextValueColumn"].ToString();
droplist.DataValueField =
dst.Tables[0].Columns["DataValueColumn"].ToString();
droplist.DataBind();

***************************
this.Label1.Text = droplist.SelectedItem.Text;
this.Label2.Text = droplist.SelectedItem.Value;

Can you help me?

(sorry for my english, but I'm italian....!)
 
Hi People, I want populate one DropDownList with a DataSet.
I've got one problem when I pass the data and text value. My code
(propabily wrong)
pass always the first value of my droplist.

DataSet dst = new DataSet();

dst = myobject.GetDataSet();

droplist.DataSource = dst.Tables[0];
droplist.DataTextField =
dst.Tables[0].Columns["TextValueColumn"].ToString();
droplist.DataValueField =
dst.Tables[0].Columns["DataValueColumn"].ToString();
droplist.DataBind();

***************************
this.Label1.Text = droplist.SelectedItem.Text;
this.Label2.Text = droplist.SelectedItem.Value;

Can you help me?

(sorry for my english, but I'm italian....!)

Nobody can help me?
 
Don't worry - I wish I could speak Italian half as good as you speak English
are you having troubles setting the DataTextField/DataValueField, before
binding, or in the label part you had below it?
 
Back
Top