Repeater is used to bind lightweight data
Element:
Header element: headertemplate Header
Item bound to data: itemtemplate
Alternatingitemtemplate
<% # Eval ("bookname") %> bind a data element to each item
Eval (can only be used for display) bind (display and output)
Commandname = "Update" commandargument = '<% # eval ("bookid") %>'
You can set these two values to obtain the object's ID value column, for example:
<Asp: linkbutton id = "lbdelete" onclientclick = "Return confirm ('OK? Are you sure you want to delete shards? Except y ?? ') "Commandname =" delete "commandargument =' <% # eval (" bookid ") %> 'runat =" server "> Delete </ASP: linkbutton>
-------------------------------------------------------------------
Separatortemplate contains the elements presented between each item. The final penalty example may be a horizontal line (html hr element)
<Separatortemplate>
<Tr>
<TD colspan = "5">
<HR/>
</TD>
</Tr>
</Separatortemplate>
Footertemplate is the data ,,,,
Pageddatasource data Paging
Datasource-set the data source
Currentpageindex-set or get the current page
Pagesize-set or obtain the number of records per page
Allowpaging-sets whether the control implements automatic paging.
Column;
Datatable table = dbutil. gettable (SQL );
// Score? Page? Which of the following is the number of data sources? Enable? Use?
Pageddatasource PPS = new pageddatasource ();
PPS. datasource = table. defaultview; // set the data source for the datasource object
PPS. currentpageindex = pager-1; // you can specify the index of the retaining wall page.
PPS. allowpaging = true; // start the page
PPS. pagesize = 5; // The amount of sweat per page
This. rptbookinfo. datasource = PDS; // bind data
This. rptbookinfo. databind ();
--------------------------------------------------------------------
Use of datalist
Event:
Editcontrol edit event deletecontrol Delete
Updatecontrol cancelcontrol cancellation event
Element:
Itemtemplate-bound data item
Edititemtemplate: When you click Edit, the code in edititemtemplate is executed,
Commandname = "edit" commandargument = '<% # eval ("bookid") %>'
Click Edit. The preceding two attributes must be set.
// Set the click Edit item to the edit mode status.
This. dlbookinfos. edititemindex = E. Item. itemindex;
Datalistbind (); // bind data to datalist
Delete the entry and set commanname = "delete"
Onclientclick = "Return confirm ('Are you sure you want to delete the token? ') "Commandname =" delete "commandargument =' <% # eval (" bookid ") %>'
Cancel setting commanname to "cancel"
This. dlbookinfos. edititemindex =-1; // set the item to be edited to-1;
Datalistbind (); // bind data to datalist
/Obtain the bound commandargument value (usually the primary key value)
Int bookid = convert. toint32 (E. commandargument );
// Obtain the text value
String bookname = (textbox) E. Item. findcontrol ("txtbookname"). text;
E. Item. findcontrol ("txtbookname") // find a control of the following type: system. Web. UI. control must be converted to textbox to obtain its value.
Bytes -----------------------------------------------------------------------------------
Use of the gridview Control
The iid of the datakeynames object is used to add, delete, and modify
Autogeneratecolumns set whether to automatically Add rows
Fagesize: the number of lines per page
Pageindexchanging code is written when the index value is changed.
Rowdatabound is triggered after the cursor row is bound for the light stick Effect
For example: // judge whether D is disconnected? When an otter? What is the first degree of exercise? ? Row D is? No? Number of rows a according to row y d
If (E. Row. rowtype = datacontrolrowtype. datarow)
{
E. Row. Attributes. Add ("onmouseover", "currentcolor = This. style. backgroundcolor; this. style. backgroundcolor = 'yellow '");
E. Row. Attributes. Add ("onmouseout", "This. style. backgroundcolor = currentcolor ");
}
---------------------------------------------
Data Binding control notes