The gridview is intelligent and provides a lot of representations directly. It is one of the most complex and resource-consuming parts of the three. It is often used for list data processing, but it is better not to have too much data;Repeater: Actually, it is to implement the repeated display function, which has a high degree of customization. It is similar to writing a circular statement in ASP to automatically generate a data list, is linear proces
As follows:
The source code is as follows:
Copy codeThe Code is as follows: using System;
Using System. Data;
Using System. Configuration;
Using System. Collections;
Using System. Web;
Using System. Web. Security;
Using System. Web. UI;
Using System. Web. UI. WebControls;
Using System. Web. UI. WebControls. WebParts;
Using System. Web. UI. HtmlControls;
Namespace RepeaterTest{Public partial class Repeater: System. Web. UI. Page{Protected void Page_L
Five main templates:1, HeaderTemplate-header template, will be loaded at the beginning of the execution once2, FooterTemplate-foot template, load will be executed at the last time3, ItemTemplate-item template, how many times the data source data will be repeated4, AlternatingItemTemplate-alternating item template, alternating with the item template until the data in the data source has been repeatedly completedBackground binding Data:1, need to find out the datalist2. Binding displayRepeater1.da
ASP. NETData Control Overview:
1.Before3Used to present multiple records,Back2Used to display details of a single piece of data,This is commonly used record details.
2. gridview and detailsview fixed control layout , the layout function of custom data display is limited , it is generally suitable for simple data presentation. 3. datalist, repeater and formview data controls have strong custom Layout capabilities , Complex layo
= Ucar.Common.ConvertHelper.GetInteger ((RptMessList.Items.FindControl ("Hfid") as HiddenField). Value);Bomessageds Bomessmodel = Bomessage.getmodel (k);if (Bomessmodel! = null){bomessmodel.ispublisheractive = 0;Bomessage.update (Bomessmodel);Ucar.Common.ScriptHelper.ShowAlertScript (this. Page, "Delete succeeded!" ");}}}The deletion behind me is the tombstone, the replacement state, we can directly delete can thank you to appreciate!DataBind ();}Call Method:Select AllThe name is set to Allbox,
To display list data in webform, we generally use server controls such as repeater, datalist, or gridview, which are powerful and easy to use. But it also has a price,
I. No matter which control you use, you need to sacrifice some extra performance because their lifecycle is complex.
2. The data binding process is not flexible enough. The display process is not transparent. It is troublesome to control a row as you like.
3: generate a pair of "spam"
The repeater was used for debugging the graduation project today. However, when adding, editing, and deleting operations, the system encountered a problem. After the data cannot be bound to a URL,
I originally wrote
The result URL is changed to editfiletype. aspx? Id = After several review and debugging, we finally got it done:
Program code
The Repeater control is used for loop output.
Introduction:
Use of iner in Data Binding
Retrieve the num column from the containerFor example:
Database Object CreationCon. open ();Sqldataadapter sad = new sqldataadapter (); // create a data adapter objectSad. selectcommand = new sqlcommand ("select * From person", con); // instantiateDataset DS = new dataset (); // defines a dataset.Sad. Fill (DS, "info"); // use the data adap
Use You can useGridviewrow ROW = GV. Rows [convert. toint32 (E. commandargument)];Obtains the row object operated in the gridview.
In the Repeater control, use container. itemindex to obtain the serial number of the current row.
For example:
Code
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--># Convert. tostring (container. itemindex+1)%>
ASP tutorials Repeater paging for. NET List data source*/
According to the current page number, the number of pages per page, get the appropriate data.public static list{listStringBuilder sb = new StringBuilder ();Sb.append ("select top" + Pagenum + "* from Zjagzm.message where");Sb.append ("ID not in" (SELECT Top + pagenum * currentpage + "id out zjagzm.message" ORDER by uptime Desc ");DataTable dt = Dbhelpersql.getdataset (sb.tostring (), NULL);
By the way, I sorted it out for your reference:
(1). Asp.net Repeater control
1. Example Image
2. UsageCodeDownload
Http://www.cnitblog.com/Files/ChengKing/Reapter.rar
(2). Asp.net datalist Control
2. Download the usage code
Http://www.cnitblog.com/Files/ChengKing/DataList.rar
(3). Asp.net DataGrid
Note: I don't have to spend any more time organizing this control. The singles' INE has already done a great job. below is the origi
Repeater:HeaderTemplate-Execute again at load startItemTemplate-How many data are executed and how many timesFooterTemplate-executed at the end of the loadAlternatingItemTemplate-Alternating Item templateprotected void Page_Load (object sender, EventArgs e) { if (! IsPostBack) { Repeater1.datasource = new Usersda (). Select (); Repeater1.databind (); } }Stock Alert:Change the style of a piece of data after judging by a property valueProperty exten
Js Section:
Copy codeThe Code is as follows: var checkboxs = document. getElementsByTagName ("input ");
For (var I = 0; I {
If (checkboxs [I]. type = "checkbox" checkboxs [I]. checked = true ){
Var trobj = checkboxs [I]. parentNode. parentNode; // locate the tr node.
If (trobj. rowIndex> 0 ){
Var tdobj = trobj. children;
Var amount = tdobj [3]. children. item (0). value; // find the value of the td node corresponding to the 4th td
Alert (amount );
}
}
}
Html
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.