Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7942203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:53:54+00:00 2026-06-03T23:53:54+00:00

I have a data repeater with each row using a combobox. When you click

  • 0

I have a data repeater with each row using a combobox. When you click the Add button it adds a new row to the DataRepeater.

   public enum ColorTypes {Red, Green, Yellow}
   class LineItem
   {
       public ColorTypes Color {get;set;} 
   }

When you click a button on the form it then creates a new LineItem, and rebinds.

  private void btnAdd_Click(object sender, EventArgs e)
  {
       LineItem CopyItem = new LineItem();
       CurrentList= ((List<LineItem>)dataRepeater.DataSource); 

       CurrentList.Add(CopyItem);
       dataRepeater.DataSource = CurrentList;
  }

This correctly adds a new row to the DataRepeater, but now changing combobox’s index modifies both rows. Is there some special binding you need to perform?

Heres my binding code:

 this.cbPackage.DataSource = System.Enum.GetValues(typeof(ColorTypes));
 this.cbPackage.DisplayMember = "Color";
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T23:53:55+00:00Added an answer on June 3, 2026 at 11:53 pm

    After a LOT of searching and putting things together, you CAN pull this off! In order to properly use a combo box in a DataRepeater you will need to add the following events.

    this.dataForm.ItemCloned += new Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventHandler(dataForm_ItemCloned);
    this.dataForm.DrawItem += new Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventHandler(dataForm_DrawItem);
    this.cbPackage.SelectedIndexChanged += new System.EventHandler(cbColor_SelectedIndexChanged);
    

    MSDN ItemCloned

    MSDN DrawItem

    Now when the ItemCloned event is called you need to find your combo box control and manual map the data source (this prevents the dropdowns from using the same source and share the same selected index)

        void dataForm_ItemCloned(object sender,                Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs e)
        {
            var combo = (ComboBox)e.DataRepeaterItem.Controls.Find("cbColor", false)[0];
            //Set the data source
            Combo.DataSource = System.Enum.GetValues(typeof(DataRepeater.ColorTypes));
        }
    

    If your data changes on an add row, or you need to redraw the repeater the combo box index will be set to null. So to fix it, after the item template is done you’re going to have to reset the selected index on draw.

        /// <summary>
        /// After Item is cloned, draw item. The index is now available to select the proper data
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void dataForm_DrawItem(object sender, Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs e)
        {
            var dataRepeater = (Microsoft.VisualBasic.PowerPacks.DataRepeater)sender;
            var combo = (ComboBox)e.DataRepeaterItem.Controls.Find("cbPackage", false)[0];
            //Set the selected item based of the list item index
            Combo.SelectedItem = ((List<LineItem>)DataRepeater.DataSource)[e.DataRepeaterItem.ItemIndex].PackageType;  
        }
    

    Finally, the last issue occurs when you change the value of the dropdown. The datasource does not get updated automatically. So now you need to manually update the source based of the index of the combobox.

     void cbPackage_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            var combo = (ComboBox)sender;
            var dataRepeaterItem = (Microsoft.VisualBasic.PowerPacks.DataRepeaterItem)combo.Parent;
            var dataRepeater = (Microsoft.VisualBasic.PowerPacks.DataRepeater)combo.Parent.Parent;
            var source = ((List<ColorData>)DataRepeater.DataSource)[DataRepeaterItem.ItemIndex];
            source.PackageType = (DropData)combo.SelectedValue;        
        }
    

    Wow… There you go, everything should be all set.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a repeater that's bound to a SQL Data Source (using ASP.NET). Are
Using SQL Server, have a name value pair table. Each row is basically userid,
I have a Repeater control that adds rows to a table. The data inside
I have a repeater for showing my data . this repeater showing 2 field
I have a Repeater in my page and after databinding, I have to click
I have 2 Repeaters one inside another. <div id=result> <asp:Repeater runat=server id=results> <Itemtemplate> <asp:Button
I have a repeater for different updates identified by Update_ID. Each Update_ID has a
I am trying to place a repeater within a repeater using xml data. I
I have a Page with 2 repeaters on it and each repeater contains a
I currently have a table with a repeater that is being filled with data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.