Nested Repeaters
pixabay

Nested Repeaters

Let's take an example. We have Categories table in our DB, and each Category has multiple subcategories. How can I bind these into our web page, letting the user select one or more subcategory?

So, first I will establish an "outer" repeater that holds the Category data. Then an "inner" repeater that holds the Subcategory data. Should look like this

No alt text provided for this image

Now, let's bind the outer repeater with our Categories data

No alt text provided for this image

For each Category, we need to link the relevant Subcategory. So we bind the inner repeater, this time with the ID of the relevant Category, which is stored in Hidden Field component.

No alt text provided for this image

All we need to do is to catch the Checkbox inside the "inner" repeater, so we can verify it is selected. This can be done by looping the two repeaters in a nested for-each. In case the checkbox IS selected, we are free to do our whatever manipulation needed.

No alt text provided for this image


要查看或添加评论,请登录

Orsan Awawdi的更多文章

  • Docker Disk Space Management

    Docker Disk Space Management

    It is necessary to regularly check the disk space occupied by Docker to ensure efficient resource management and…

  • Code Review

    Code Review

    Code Review is a sensitive matter. It introduces the code you wrote to the eyes of another person, who has their own…

  • re.findall

    re.findall

    When we talk about finding recurrent text in a string, we think about regex (Regular Expressions). Regex has so many…

    1 条评论
  • AI generated code

    AI generated code

    Should we always listen to AI generated code? I asked BLACKBOX.AI to write me a simple code in #python.

  • Environment variables

    Environment variables

    Environment variables are variables that store data in your program but outside your code. For example, key and secret…

    1 条评论
  • Understanding type annotation in Python

    Understanding type annotation in Python

    Why do we need type hints in Python? We can annotate (comment) variables and functions with data types. Being a…

  • Process transcript with Python

    Process transcript with Python

    Let's see what is the most popular word from Donald Trump speech. Transcript of the speech can be found when googling…

  • Three options to filter a list in C#

    Three options to filter a list in C#

    I will show here three different ways to filter text by some string criteria in C#. We have a public class called…

  • Validation using Attributes in C#

    Validation using Attributes in C#

    Validating data entered by user can be done via multiple methods. Attributes is one powerful yet simple way to validate…

社区洞察

其他会员也浏览了