TransWikia.com

Asp.net generate cards instead of using GridView to do so dynamically

Stack Overflow Asked on December 3, 2021

I’m quite new to ASP.NET Web Form. How can we generate cards dynamically with the same idea as using GridView in ASP.NET VB language?

2 Answers

If you are new to ASP.NET, you should also look at DataList control. It's similar to the Repeater control but easier to use as you don't have to "code" the templates yourself, you can design them in the page directly.

Answered by A.Buonanni on December 3, 2021

You can use Repeater Control which is used to display the repeated list of items in your own style in your case 'card'.

Repeater Control is used to display repeated list of items that are bound to the control and it’s same as gridview and datagridview. Repeater control is lightweight and faster to display data when compared with gridview and datagrid. By using this control we can display data in custom format but it’s not possible in gridview or datagridview and it doesn’t support for paging and sorting.

The Repeater control works by looping through the records in your data source and then repeating the rendering of it’s templates called item template. Repeater control contains different types of template fields those are

  1. ItemTemplate
  2. AlternatingItemTemplate
  3. HeaderTemplate
  4. FooterTemplate
  5. SeperatorTemplate

ItemTemplate: ItemTemplate defines how the each item is rendered from data source collection.

AlternatingItemTemplate: AlternatingItemTemplates is used to change the background color and styles of AlternatingItems in DataSource collection

HeaderTemplate: HeaderTemplate is used to display Header text for DataSource collection and apply different styles for header text.

FooterTemplate: FooterTemplate is used to display footer element for DataSource collection

SeparatorTemplate: SeparatorTemplate will determine separator element which separates each Item in Item collection.

For more information Repeater - Microsoft Documentation

Answered by Jawad Anwar on December 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP