Cascading dropDownLists in a repeater. DropDownLists with SQL source code and add / remove

What is the trick for implementing the following interface in ASP.NET?

repeater

I think the screenshot should explain everything.

  • Both dropDownLists work with SQL tables. [Categories], [Items] related to Category_ID PK / FK
  • Number of lines (default 1 line with "Add" button)
  • Selecting a category only changes the content of the dropDownList next to it, and the content remains unchanged when other rows are added / removed.
  • The "Add" button saves the current setting and adds a new line with "Select a value" or eventually 1st category / 1st selected item

How to keep previously selected categories / items and filtering DropDown by category when adding, modifying, deleting items or some other PostBack on the website?


I tried to use Repeater with DataSet, however I ran into several different problems:

  • Failed to save relationship between previous dropDowns
  • Droppable DropDowns
  • 2nd dropDown plays filtering when new line is added

I can post some code, but since it doesn't work completely, perhaps a completely different approach would be better. I basically started with this tutorial. The repeater currently looks like this:

<repeater>
<itemtemplate>
  <dropDown DataSource="categoriesDS" 
     value='<%# DataBinder.Eval(Container.DataItem, "Category") %>'.../>
  <dropDown DataSource="itemsDS" 
     value='<%# DataBinder.Eval(Container.DataItem, "Item") %>'.../>
  <button CommandName='<%# DataBinder.Eval(Container.DataItem, "Button") %>' 
     Text='<%# DataBinder.Eval(Container.DataItem, "Button") %>' .../>
</itemtemplate>
</repeater>

      

Thanks in advance for any suggestions or solutions, and I hope this is helpful to others.

+3


source to share


1 answer


Ajax Cascading DropDownlist



This is a very simple use.

+1


source







All Articles