I always want to ask in C # me a I want to get it listed in 4 of the 4 columns, which I've typically finished using Is there a better way to do this? You IEnumerable & lt; Cars & gt; , which has 20 results in my SQL database with a LINQ query.
ul tags first
ul Then start
foreach through the numerator, place a counter in it when it closes
% 5 == 0 i
ul And after a new ... start
foreach , add the ending
ul .
GroupBy () the way to collect cars together You want to present them, in your case, 5 cars are grouped together (using the integer division, cars with 0 to 4 index, group 1, group 5 to 9, group 2 etc.):
list & lt; Cars & gt; Cars = New list & lt; Cars & gt; (); // Various car groups of cars = cars. Choose (car, index) = & gt; New {index = index, car = car}) .GroupBy (x => x.Index / 5) Select (G = & gt; G.Select (x = & gt; x.Car) .Olist ()) .Olist (); Forchha (different groups in the car group) {// Amit & lt; UL & gt; Foreign (different cars in the group) {// Amit & Lieutenant; LIT & gt; // Amit with car details} / UL> }
Comments
Post a Comment