Add extra repeater item or loop from the code behind

Leeyoh_it_is

I am trying to create a 5 personalised quick links options for a user. I know that repeater items are generated from the datasource. These quick link fields by default have an add or delete link option. What should I do if datasource returns just 3 and I still want want to add the 2 extra controls.

Right now I created 5 controls statically, which I don't really like. Sorry I am really new to C#. Googled hard...maybe not hard enough...still googling right now. Thank you in advance for any suggestions or tips.

Here's an example

  • link1 x
  • link2 x
  • link3 x
  • _____ +
  • _____ +
vwseppe

So if I understand well:

You retrieve 0-5 links from a datasource which you want to show. If links < 5 you want to show the others as blank with a '+' sign?

There are plenty of solutions for this. From your tags I'll assume you will be using ASP.NET so: In your view when you acces your data from Viewbag or Model I'll call it 'list'

@{
    int i = 0; //Counting your items can also be done by length of list
}
<ul>
@foreach(var link in list)
{
    <li>@link.Name <span class="delete">-</span></li>
    i++;
}
@for(j=0;j<i;j++)
{
    <li>__<span class="add">+</span></li> 
}
</ul>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to add Repeater control dynamically from code behind?

From Dev

How to Fill Repeater ItemTemplate from Code Behind?

From Dev

Get a value from Repeater in code-behind

From Dev

How to get Footer Item value on code behind with nested Repeater?

From Dev

How to get Reference to the label in repeater item in code behind

From Dev

Give asp:hyperlink in a repeater a url from code behind

From Dev

How to call javascript from code behind for Repeater control

From Dev

Calling code behind functions from ajax call and display item by item

From Dev

Add images to div from Code Behind

From Dev

Add twitter glyphicon from code behind

From Dev

How to call code-behind code from a unordered list item

From Dev

how can i change the repeater's label value from code behind

From Dev

Change visibility of RadioButton item from code behind VB.NET

From Dev

How to change a listbox unselected item colour from code behind

From Dev

How to add extra item in asp .net mvc dropdownlist from controller

From Dev

ACF Add Class if first item in repeater array

From Dev

Gridview dataBound add hyperlink to column data from code behind

From Dev

How to add a control from code-behind in a DIV

From Dev

Asp.net add form onsubmit() from code behind

From Dev

Windows Phone 8: Add FrameworkElement to PanoramaItem from code behind

From Dev

Add comboBox items from code behind. [WPF]

From Dev

Add DataGrid.Columns from code behind in WPF

From Dev

Gridview dataBound add hyperlink to column data from code behind

From Dev

Add an image source to ContentControl from C# code behind

From Dev

Use DataItem in Code-behind to set class or style in Nested Repeater

From Dev

how to add if condition during the loop in angular repeater

From Dev

Delete an item from an asp:Repeater using jQuery

From Dev

Exception thrown when trying to remove pivot item (with header template) from code behind windows phone

From Dev

Accessing children of second pivot item from code behind with their x:Name returns null in Windows Phone 8.1

Related Related

  1. 1

    How to add Repeater control dynamically from code behind?

  2. 2

    How to Fill Repeater ItemTemplate from Code Behind?

  3. 3

    Get a value from Repeater in code-behind

  4. 4

    How to get Footer Item value on code behind with nested Repeater?

  5. 5

    How to get Reference to the label in repeater item in code behind

  6. 6

    Give asp:hyperlink in a repeater a url from code behind

  7. 7

    How to call javascript from code behind for Repeater control

  8. 8

    Calling code behind functions from ajax call and display item by item

  9. 9

    Add images to div from Code Behind

  10. 10

    Add twitter glyphicon from code behind

  11. 11

    How to call code-behind code from a unordered list item

  12. 12

    how can i change the repeater's label value from code behind

  13. 13

    Change visibility of RadioButton item from code behind VB.NET

  14. 14

    How to change a listbox unselected item colour from code behind

  15. 15

    How to add extra item in asp .net mvc dropdownlist from controller

  16. 16

    ACF Add Class if first item in repeater array

  17. 17

    Gridview dataBound add hyperlink to column data from code behind

  18. 18

    How to add a control from code-behind in a DIV

  19. 19

    Asp.net add form onsubmit() from code behind

  20. 20

    Windows Phone 8: Add FrameworkElement to PanoramaItem from code behind

  21. 21

    Add comboBox items from code behind. [WPF]

  22. 22

    Add DataGrid.Columns from code behind in WPF

  23. 23

    Gridview dataBound add hyperlink to column data from code behind

  24. 24

    Add an image source to ContentControl from C# code behind

  25. 25

    Use DataItem in Code-behind to set class or style in Nested Repeater

  26. 26

    how to add if condition during the loop in angular repeater

  27. 27

    Delete an item from an asp:Repeater using jQuery

  28. 28

    Exception thrown when trying to remove pivot item (with header template) from code behind windows phone

  29. 29

    Accessing children of second pivot item from code behind with their x:Name returns null in Windows Phone 8.1

HotTag

Archive