-3

I am Trying to use array to assign movie titles to list box. They select the movie in the drop down list then it shows up in the list box (this does not work) using C# and aspx

  protected void addToCartImageButton_Click(object sender, ImageClickEventArgs e)
  {

    string [] movieNameArray = new string [10];

    movieNameArray[0] = "The Advengers";
    movieNameArray[1] = "Titanic";
    movieNameArray[2] = "Frozen";
    movieNameArray[3] = "Boy";
    movieNameArray[4] = "Grown Ups";
    movieNameArray[5] = "Coach Carter";
    movieNameArray[6] = "More than a game";
    movieNameArray[7] = "Harry Potter";
    movieNameArray[8] = "Avatar";
    movieNameArray[9] = "Titanic";



    cartListBox.Items.Add(movieNameArray.ToString());
    DropDownList3.Items.Add(movieNameArray.ToString());

}
2
  • It would be better if you asked a question in the form of a question and not a statement about what you hope to achieve. Commented May 20, 2014 at 3:05
  • But what is your exact question? I dont see any question here. Please if you are asking something then ask it properly with proper details. Commented May 20, 2014 at 3:10

1 Answer 1

3

You can bind your dropdown to the array. I.e. Instead of

DropDownList3.Items.Add(movieNameArray.ToString());

Use

DropDownList3.DataSource = movieNameArray;
DropDownList3.DataBind(); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.