[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


multiple dropdownlist controls for order items

Posted on 2008-11-07
Medium Priority
Last Modified: 2012-05-05
On the order confirmation page for an ecommerce site, I am putting together a file upload control for customer to upload graphic files for the order. I've got a dropdownlist that pulls a print location from each order item  and adds that location to the file name as it is uploaded. One of the things I'm having trouble with is getting the dropdown list to repeat for each order item. It will do it for only the first item. How can I get it to repeat?
Here is the current code:
foreach (OrderItem item in _Order.Items)

            if (item.Inputs.Count > 0)
               DropDownListTemplateFields.DataSource = item.Inputs;
               DropDownListTemplateFields.Items.Insert(0, " - Select Print Location From List - ");
               DropDownListTemplateFields.Items.Add("One File for all Print locations");
               DropDownListTemplateFields.Items.Add("Sound File(s)");

Question by:jmestep
  • 4
  • 3

Assisted Solution

tiagosalgado earned 2000 total points
ID: 22909312
You can use ASP.NET Repeate Control for that.

Author Comment

ID: 22909468
Duh, I should have thought of that. I am also trying to show the product name, then the ddl, then next product name, then ddl. That might be a way to do both- use the header. I'll try tomorrow and post back.

Expert Comment

ID: 22909497
Yes, in Repeater control, you can include all information that you want to repeat.
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 22914431
Now the page can't find the dropdown list:
<asp:Repeater ID="OrderItemRepeater" runat="server" EnableViewState="true">
            <asp:DropDownList ID="DropDownListTemplateFields" Visible="true" runat="server"  DataTextField="Name" DataValueField="OrderItemInputId"  EnableViewState="true">
            <asp:ListItem Value="" Text=""></asp:ListItem>


Expert Comment

ID: 22914584
To get all dropdownlists in your reapeter you need to do this

string _value = "";
        foreach (RepeaterItem item in OrderItemRepeater.Items)
            DropDownList d = item.FindControl("DropDownListTemplateFields") as DropDownList;
            if (d != null)
                _value = d.SelectedValue;

Open in new window


Accepted Solution

jmestep earned 0 total points
ID: 22914721
I think I'm making progress.
Later on in the class, I use the value selected in the dropdown list and I've got an error there

 protected void UploadButton_Click(object sender, EventArgs e)
        bool success = true;
        if (UploadedFile.HasFile)
            if (UploadedFile.PostedFile.ContentLength < 204800000)//195MB
                string selectedItem = DropDownListTemplateFields.SelectedItem.Text;
How can I pick up the value now? I've tried _value and d.SelectedItem.Text


Author Comment

ID: 22921815
I think what I need to do is move the code that validates the upload out of the button click and then put code on each button click that is generated within the repeater to call it?

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question