ListBox
Item Template
This sample shows how to use ItemTemplateId to specify custom content in ListBox.
Features
PlayStation 3
3
Wii U
2
XBOX ONE
2
Wii U
1
PlayStation 3
2
PlayStation 3
1
Wii U
3
PlayStation 4
2
PlayStation 3
4
XBOX ONE
4
PlayStation Vita
2
PlayStation Vita
2
XBOX ONE
3
Wii U
4
PlayStation Vita
3
XBOX ONE
4
PlayStation 3
3
XBOX ONE
2
PlayStation Vita
1
PlayStation Vita
4
Wii U
2
Wii U
4
PlayStation Vita
2
PlayStation Vita
2
XBOX ONE
1
PlayStation Vita
4
PlayStation 3
4
PlayStation 4
1
PlayStation 3
1
Wii U
3
XBOX ONE
1
PlayStation Vita
4
Wii U
3
PlayStation 4
2
PlayStation Vita
3
PlayStation 3
3
PlayStation 3
3
PlayStation 4
2
Wii U
2
Wii U
3
PlayStation 4
1
PlayStation Vita
3
PlayStation 3
1
Wii U
1
PlayStation 4
2
XBOX ONE
1
PlayStation 4
4
PlayStation 4
2
Wii U
2
PlayStation 3
4
PlayStation 4
1
Wii U
3
PlayStation 3
3
PlayStation 4
3
XBOX ONE
4
PlayStation Vita
3
PlayStation 4
4
PlayStation 3
2
Wii U
4
PlayStation Vita
2
PlayStation 3
1
PlayStation 3
4
PlayStation 4
1
PlayStation 4
3
XBOX ONE
4
PlayStation 3
2
PlayStation Vita
3
PlayStation Vita
3
PlayStation 3
1
Wii U
2
XBOX ONE
3
Wii U
1
Wii U
1
Wii U
2
PlayStation 4
1
Wii U
2
Wii U
4
PlayStation Vita
1
Wii U
1
XBOX ONE
4
XBOX ONE
2
PlayStation 3
3
XBOX ONE
4
Wii U
2
XBOX ONE
2
PlayStation Vita
4
XBOX ONE
2
PlayStation Vita
4
PlayStation 3
2
XBOX ONE
2
Wii U
2
PlayStation Vita
1
PlayStation Vita
4
XBOX ONE
3
PlayStation 4
4
Wii U
1
PlayStation 4
1
Wii U
1
PlayStation 4
4
XBOX ONE
1
Description
This sample shows how to use ItemTemplateId to specify custom content in ListBox.
You can put C1 MVC controls in a template.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | using System.Linq; using Microsoft.AspNetCore.Mvc; using MvcExplorer.Models; namespace MvcExplorer.Controllers { public partial class ListBoxController : Controller { public ActionResult ItemTemplate() { var list = CustomerOrder.GetOrderData(100).ToList(); return View(list); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | @model List< CustomerOrder > < style > .badge { color: white; background-color: darkred; border-radius: 10px; padding: 1px 10px; } .label { color: black; background-color: orange; border-radius: 10px; padding: 1px 10px; } </ style > < div > < label > @Html .Raw(ListBoxRes.ItemTemplate_CustomHTML)</ label > < c1-list-box width = "300px" height = "250px" > < c1-input-item-template > < span > < span class = "label" >{{Product}}</ span > < span class = "badge" >{{Count}}</ span > </ span > </ c1-input-item-template > < c1-items-source source-collection = "@Model" ></ c1-items-source > </ c1-list-box > </ div > < div > < label > @Html .Raw(ListBoxRes.ItemTemplate_C1MVCControls)</ label > < c1-list-box width = "300px" height = "250px" > < c1-input-item-template > < span > < c1-input-number template-bindings = "@(new { Value = " Count "})" min = "0" max = "10" step = "1" is-template = "true" ></ c1-input-number > </ span > </ c1-input-item-template > < c1-items-source source-collection = "@Model" ></ c1-items-source > </ c1-list-box > </ div > @section Description{ < p > @Html .Raw(ListBoxRes.ItemTemplate_Text0)</ p > < p > @Html .Raw(ListBoxRes.ItemTemplate_Text1)</ p > } |