Friday 15 July 2011

webforms - Displaying multiple dynamic posts using asp.net -


I am new to asp.net (web form) and want to get some information from database and then this information If there are three rows in the form of posts, such as title, paragraph and an image, then there will be three terms. I used the asp code in the .aspx file

  & lt;% while (reader.Read ()) {%> & Lt; Article class = "call 1" & gt; & Lt; H2 & gt; & Lt;% = reader.GetValue (0). Ostring ()%> & Lt; / H2 & gt; & Lt; P class = "pad_bot1" & gt; & Lt;% = reader.GetValue (1). Ostring ()%> & Lt; / P & gt; & Lt; Img src = "& lt;% = reader.GetValue (2). Ostring ()% & gt;" Class = "img" alt = "" & gt; & Lt; / Article & gt; & Lt;%} Reader. Stop it (); & Gt%;   

But I have read somewhere that the code should be different and it should be written in the .aspx.cs file. What's the way to do this? Specify the IDs on H and P tags and then assume them:

  while (reader.Read ()) {h.InteText = reader.GetValue (0) .ToString (); P.InnerText = reader.GetValue (1) .ostring (); }   

But this does not solve the problem, because the terms will not appear in the loop ie 3 times.

I want to know the most suitable solution, thanks in advance

This is my code

Back to the code

  // This is your object that you can see the private category product {public string ProductName {get; Set; } Public string ProductDescription {get; Set; } Public string ProductPrice {get; Set; }} // Here you are passing the Private Waste Bid Items InCart (List & lt; Products & gt; List selected selected products) in the list of products {// List the source of data as this. Rpts inkart.data source = list-selected product; // Then bind the repeater // Public properties become columns of your repeater. RptItemsInCart.DataBind (); }   

ASPX code

  & lt; Asp: Repeater id = "rptItemsInCart" runat = "server" & gt; & Lt; HeaderTemplate & gt; & Lt; Table & gt; & Lt; Thead & gt; & Lt; TR & gt; & Lt; Th & gt; Product name & lt; / Th & gt; & Lt; Th & gt; Product Details & lt; / Th & gt; & Lt; Th & gt; Product Price & lt; / Th & gt; & Lt; / TR & gt; & Lt; / Thead & gt; & Lt; Tbody & gt; & Lt; / HeaderTemplate & gt; & Lt; ItemTemplate & gt; & Lt; TR & gt; & Lt; Td> & Lt;% # Eval ("Product Name")%> & Lt; / Td> & Lt; Td> & Lt;% # Eval ("Product Description")% & gt; & Lt; / Td> & Lt; Td> & Lt;% # Eval ("Productivity")% & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; / ItemTemplate & gt; & Lt; FooterTemplate & gt; & Lt; / Tbody & gt; & Lt; / Table & gt; & Lt; / FooterTemplate & gt; & Lt; / ASP: Repeater & gt;    

No comments:

Post a Comment