multiple dropdownlist controls for order items

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.DataBind();
               DropDownListTemplateFields.Items.Insert(0, " - Select Print Location From List - ");
               DropDownListTemplateFields.Items.Add("One File for all Print locations");
               DropDownListTemplateFields.Items.Add("Sound File(s)");
             
            }

upload.gif
jmestepAsked:
Who is Participating?
 
jmestepConnect With a Mentor Author Commented:
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

Thanks
0
 
tiagosalgadoConnect With a Mentor Commented:
You can use ASP.NET Repeate Control for that.
http://www.sitepoint.com/article/asp-net-repeater-control/
 
0
 
jmestepAuthor Commented:
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.
Thanks,
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
tiagosalgadoCommented:
Yes, in Repeater control, you can include all information that you want to repeat.
0
 
jmestepAuthor Commented:
Now the page can't find the dropdown list:
<asp:Repeater ID="OrderItemRepeater" runat="server" EnableViewState="true">
             <ItemTemplate>  
            <asp:DropDownList ID="DropDownListTemplateFields" Visible="true" runat="server"  DataTextField="Name" DataValueField="OrderItemInputId"  EnableViewState="true">
            <asp:ListItem Value="" Text=""></asp:ListItem>
            </asp:DropDownList>
            </ItemTemplate>

            </asp:Repeater>
0
 
tiagosalgadoCommented:
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

0
 
jmestepAuthor Commented:
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?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.