Forums - C# Corner

Forum guidelines
Administrator

Administrator

  • Admin
  • 2.2k
  • 1.3m

Small problem with dropdownlists.. please help!

Apr 16 2003 1:39 PM
Small and easy problem that I cant figure out. I have a dataset which i am filling using a database. I am then populating a dropdownlist from the dataset. In the properties for the dropdownlist i have set the DataTextField and DataValueField to fields in my dataset/database. When i run the app the dropdownlist Text is correctly populated and i believe the Value is right too. My problem is when i try to save the information back to the dataset/database .. It only returns the first option in my dropdownlist. So for example i select the 3rd item in my dropdownlist and when i hit the Save button on my App it saves the info back to the dataset/database .. but it saves the 1st item and not the 3rd. Why is it only saving the first item? here is some of my code.. // - creating and populating a dropdownlist with info from a dataset which is conectd to a DB // - in PageLoad() ddlName.DataSource = dsDataSet.T_TableName; ddlName.DataBind(); // - in SaveButton_Click(.. row.ValuetoSave_INT = int.Parse(ddlName.SelectedItem.Value); Everything in my form saves correctly except for my downdownlists. They all return 1 and not the value the user chooses. Please help!!

Answers (2)