This article is a detailed introduction to the built-in object Session object and Application global object shared by the editor of the Error New Technology Channel. I hope it will be helpful to your future learning.
Session
Each computer accesses the server and has an independent session, the key values are the same, and the contents are different.
1.session is saved on the server.
2. The session has no persistence and the storage period is 20 minutes.
Key points: Don’t abuse the session, don’t use it. Abuse will cause server overflow, and do not use it will cause resource waste.
Assignment: Session["key"] = value;
Value: string a = Session["key"];
Clear: Session["key"]=null;
Application
Application["key"] is that all users get the value in this key. There is no saving cycle, and it will be saved all the time, usually used as the version number.
Assignment: Application["key"]=value;
Value: Application.Get("key");
Repeater's Command Operation:
example:
<ItemTemplate> <tr style="<%#Eval("Blue") %>" > <td><%#Eval("UserName") %></td> <td><%#Eval("Password") %></td> <td><%#Eval("NickName") %></td> <td><%#Eval("SexName") %></td> <td><%#Eval("birthdayn" )%></td> <td><%#Eval("Age" )%></td> <td><%#Eval("NationName") %></td> <td><asp:Button ID="Button1" runat="server" Text="Delete" CommandName="delete" CommandArgument='<%#Eval("UserName") %>'/> <asp:Button ID="Button2" runat="server" Text="Modify" CommandName="xiugai" CommandName="delete" CommandArgument='<%#Eval("UserName") %>' /> </td> </tr> </ItemTemplate>Background code:
if (e.CommandName == "delete")//Delete button { new UserDA().delete(e.CommandArgument.ToString()); Repeater1.DataSource = new UserDA().select(); Repeater1.DataBind(); } if (e.CommandName == "xiugai") { new UserDA().select(e.CommandArgument.ToString()); Repeater1.DataSource = new UserDA().select(); Repeater1.DataBind(); }Through the introduction of the new technology channel, the built-in objects of the new technology channel, the Session object of the new technology channel, the ViewState, I hope it can help you learn this part of the knowledge. Thank you for your support of the new technology channel!