I'm new to ASP.NET and are trying to create a list with content from a database. I have been struggling with GridView, but it seems to give me an headache....
If I want to create a list with data from an database, and do some formatting and tricks with links etc, how should I do it?
For example a hit list on eBay, which has data from several columns, images, links with id:s included etc. http://www.ebay.com/sch/i.html?_from=R40&_trksid=p5197.m570.l1313&_nkw=asp.net&_sacat=See-All-Categories
Which control should I use to create the list, and how do I create the Html on each row?
Appreciates all help I can get!
preguntado el 03 de mayo de 12 a las 18:05
As mentioned in my comment, using a
Repeater will give you all the flexibility while saving you the trouble to create your html from code-behind.
<asp:Repeater ID="MyRepeater" runat="server"> <HeaderTemplate> <div class="ListDiv"> <h2>My headline</h2> </HeaderTemplate> <ItemTemplate> <div class="ItemDiv"> <a href='<%# DataBinder.Eval(Container.DataItem, "ProductLink") %>'> <%# DataBinder.Eval(Container.DataItem, "ProductName")%> </a> </div> </ItemTemplate> <FooterTemplate> </div> </FooterTemplate> </asp:Repeater>
Admittedly MVC is modern and state-of-the-art but may give you a steep learning curve.
People could argue that when new to both WebForms and MVC you should rather embark on learing MVC than WebForms.
If you need to deliver something, imho WebForms will give you results faster (when new to ASP.NET in general).