First, the use of repeater
Used to display data
Second, the use of repeater steps
Step1: Drag a Repeater control into the Web page. In the background code, specifying its data source requires a list generic collection.
Public Partial class query:system.web.ui.page{ protectedvoid Page_Load (object sender, EventArgs e) { new Fruitda (). Select(); Repeater1.databind (); }}
Step2. Edit the column name in the source code, specifying the property name of the data that needs to be displayed.
Run results
View Source code
Tips:
Repeater doesn't show anything in the Web page, it just passes the text data to the Web page. Is the same as the literal control.
Third, Hyperlink transfer data
Add an event to a new page
protected void Page_Load (object sender, EventArgs e) { Response.Write (request["Ids " ]); }
Run results
Click on "Pineapple"
Tip: When you transfer data with a hyperlink, you can see the URL change in the status bar below when the mouse is over the hyperlink. You can also see the difference in the address bar of a new page that accepts data.
Iv. Comprehensive Application
㈠ displaying data in a Web page in tabular form
Essence: Use the Repeater control to spell the string.
Run results
㈡ the use of alternating item labels <AlternatingItemTemplate>.
<ItemTemplate> <TR> <TDbgcolor= "Blue"><%#Eval("Ids") %> </TD> <TD><%#Eval("Name") %></TD> </TR> </ItemTemplate> <AlternatingItemTemplate> <TDbgcolor= "Green"><%#Eval("Ids") %> </TD> <TD><%#Eval("Name") %></TD> </AlternatingItemTemplate>
Run results
When the data is displayed, the item label and alternating item label are executed alternately, the item label is executed first, and the alternating item label is executed.
㈢ additions and deletions to search
Step1. Transferring data to a new web page
<ItemTemplate> <TR> <TDbgcolor= "Blue"><%#Eval("Ids") %> </TD> <TD><%#Eval("Name") %></TD> <TD><ahref= "Delete.aspx?" ids=<% #Eval ("Ids ")%>The > Delete</a><a>Modify</a> </TD> </TR> </ItemTemplate>
Step2. Receives data from a hyperlink in a new page load event, calls the delete data function based on that data, and then returns to the original page.
protected void Page_Load (object sender, EventArgs e) { Response.Write (request["Ids " ]); New FRUITDA (). Delete (request["Ids"]); Response.Redirect ("query.aspx"); }
Run the result, click Delete after "Pineapple",
Before clicking,
When clicked,
Because the page loading speed, so do not see the loading of the deleted page, the original page seems to have never left.
Use of the C#repeater control