1. Data binding
Combox-->bingdsource-->objectdatasource
Connecting to a database
* * Background code:
T_usertableadapter Adpter=t_usertableadpter ();
Adpater. Call the custom method of the T_user table
Set Initial data:
Appenddatebource= "true";
2, Repeater dynamic display of data table all data: (equivalent to A for statement I think)
#代表绑定数据
(1, Template:<itemtemplate> primary key: <% #Eval ("Id")%> </ItemTemplate>
(2, other templates (interlaced display):<alternatingtemplate></alternatingtemplate>
(3, also has the head tail template <HeaderItemplate> also has the <FooterItemplate>
(4. Service-side functions can be invoked in <%AAA (Eval ("a"))%>
Protected string AAA (object URL) {
Return Resolveclienturl ("/.. /"+url);
}
(5, common types of statements:
**1:e. item.itemtype==listitemtype.item| | E.item.itemtype==listitemtype.alternatingitem
Refers to the underlying row or content row in the Dadalist type: used to determine whether an item is an item or an intersection in a control's content
**2:e. Item.itemtype = = Listitemtype.header
Refers to the contents of the header row in the trigger type Dadalist: the header used to determine whether the item is a control
**3 Search Information:
ListItemType enumeration [C #] See
System.Web.UI.WebControls Namespaces | Datagriditem.itemtype | Datalistitem.itemtype | Repeateritem.itemtype
Namespaces: System.Web.UI.WebControls
The ListItemType enumeration represents the different items that can be contained in a list control, such as the DataGrid, DataList, and Repeater. A typical list control consists of cells that contain the elements represented by this enumeration.
Members
Description of Member name
AlternatingItem an item in a cell alternating (zero-based even index). It is data-bound.
An item in the EditItem list control that is currently in edit mode. It is data-bound.
The footer for the Footer list control. It is not data-bound.
Header of the header list control. It is not data-bound.
Item in the item list control. It is data-bound.
Pager page navigation that displays the controls that navigate to the different pages associated with the DataGrid control. It is not data-bound.
SelectedItem the selected item in the list control. It is data-bound.
Separator the separator between items in a list control. It is not data-bound.
3. The ItemDataBound event of the repeater event
(1, Onitemdatabound event (get the same row related information in the binding)
DataRowView myrow= (DataRowView) e.Item.DataItem;
Myrow["Here is the related field name"]
(2, Background code: Get the columns in the database table
To remove information from a bound row
DataRowView view= (DataRowView) e.Item.DataItem;
Strong connection
var row= (project name/folder name/dal/datasetpersons/t_personsrow) view. Row;
(3, Background code: The master version of the ID can not be directly taken
Get ID
TextBox txtid= (textbox) E.item.findcontrol ("id");
Action based on ID
txtid.backcolor=color.red;
(4, ASPX: href= ' <% #Eval ("URL")%> '
So click in the browser is not to the specified page, should be changed to
Href= ' http://<% #Eval ("URL")%> '
(5, ASPX: Support format
<% #Eval ("Date", "Yyyy-mm-dd")%>
4. The ItemCommand event of the repeater event
* * E.commandname Name
* * E.commandargument Parameters
* * Background code to obtain the front-handed parameters such as Id:long Id=convert.toint64 (e.commandargument);
* * Background code: repeater.databing//Force Refresh Data
(1, onclientclick= "return confirm" do you really want to operate?) ");"
(2, see the type of ID in aspx, you can first top an ID, and then in Aspx.cs to see what type it is
The following usage:
HtmlTableRow tr= (HtmlTableRow) E.item.findcontrol ("id");
Custom attributes:: CSS specific implementation in the page, the background is just reference
* * Background code: TR. Attributes["Class"]= "the. id" in CSS;
(3, throw error: Throw new Exception ("The type of error you define");
5. Example:
Move_pic.aspx
Copy Code code as follows:
<%@ Page language= "C #" autoeventwireup= "true" codebehind= "Move_pic.aspx.cs" inherits= "Move_pic.move_pic"%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title></title>
<script src= "Scripts/jquery-1.4.1.js" type= "Text/javascript" ></script>
<body>
<form id= "Form1" runat= "Server" >
<div>
<asp:objectdatasource id= "ObjectDataSource1" runat= "Server"
Deletemethod= "Delete" insertmethod= "Insert"
oldvaluesparameterformatstring= "original_{0}" selectmethod= "GetData"
Typename= "Move_Pic.DAL.DataSet1TableAdapters.T_userInfoTableAdapter"
updatemethod= "Update" >
<DeleteParameters>
<asp:parameter name= "Original_susername" type= "String"/>
</DeleteParameters>
<InsertParameters>
<asp:parameter name= "sUserName" type= "String"/>
<asp:parameter name= "Spassword" type= "String"/>
<asp:parameter name= "Email" type= "String"/>
<asp:parameter name= "Age" type= "Int32"/>
<asp:parameter name= "Pic_url" type= "String"/>
</InsertParameters>
<UpdateParameters>
<asp:parameter name= "Spassword" type= "String"/>
<asp:parameter name= "Email" type= "String"/>
<asp:parameter name= "Age" type= "Int32"/>
<asp:parameter name= "Pic_url" type= "String"/>
<asp:parameter name= "Original_susername" type= "String"/>
</UpdateParameters>
</asp:ObjectDataSource>
<asp:repeater id= "Repeater1" runat= "Server" datasourceid= "ObjectDataSource1" >
<HeaderTemplate> Welcome to buy <table id= "TableId" ><tr></HeaderTemplate>
<ItemTemplate><td>
' a2= ' <% #Eval ("Age")%> ' width= ' "100",
height= "Src= ' image/<% #Eval (" Pic_url ")%> '/></td>
</ItemTemplate>
<FooterTemplate></tr></table> Welcome to our next visit </FooterTemplate>
</asp:Repeater>
<script type= "Text/javascript" >
/*$ ("img"). MouseMove (function (e) {
$ ("#sUserName"). Text ($ (this). attr ("A1"));
$ ("#Age"). Text ($ (this). attr ("A2"));
$ ("#divNone"). CSS ("top", E.pagey). css (' left ', E.pagex). Show ("slow");
});*/
Dynamic growth
/* $ (function () {
$ ("#img"). Click (function () {
$ (this). Animate ({"width": "+=300", "height": "+=300"});
$ (this). Animate ({"width": "+", "height": "300"});
$ (this). attr ("width", "attr"). ("Height", "300");
});
});*/
$ ("#tableId img"). MouseEnter (function () {
$ (this). Animate ({"width": ""), "height": "The", "slow");
$ (this). Siblings (). Animate ({"width": "I", "height": "300"});
To exclude oneself from the outside
$ ("#tableId img"). Not ($ (this)). Animate ({"width": ""), "height": "The"}, "slow");
});
</script>
</div>
<div style= "Display:none" id= "Divnone" >
<p> Name: <span id= "sUserName" ></span></p>
<p> Ages: <span id= "Age" ></span></p>
</div>
</form>
</body>
The database table is designed as follows: