Asp.net slide
Session 13ADO.NET - II Exploring ASP.NET / Session 13 / 2 of 31ReviewADO.NET possesses two core components:DataSet and .NET Data Provider The DataSet is the object, in which the data retrieved from the database is storedThe .NET data provider contains objects that provide access to data, and allow data manipulation with databases, and non-database data like XML The connection object is used to establish a connection between the application and the database The command object allows us to retrieve and manipulate data in the databaseThe DataGrid control can be used for viewing the records When a customized view of the data from a DataSet is required, a DataView is used.A DataReader is used when the records of the query result are viewed one after the other Exploring ASP.NET / Session 13 / 3 of 31ObjectivesUnderstand Data BindingImplement the Repeater controlImplement the DataList controlUpdate a database through a formWork with XML data Exploring ASP.NET / Session 13 / 4 of 31Data BindingData binding is the process of linking the retrieved data to the control, which will display the dataData can be bound to all types of controls with a data binding expression, which is placed between the <%# %> tags Data is bound to a control whenever the DataBind() method is called for that control. Data binding can be performed on various types of data, such as:Simple propertiesCollectionsExpressionsResult of a method call Exploring ASP.NET / Session 13 / 5 of 31Simple PropertiesASP.NET allows the developer to bind data to public variables, page properties and even other control’s properties <html><title>DataBinding </title><script language="C#" runat="server">void Page_Load(Object sender, EventArgs e) {Page.DataBind();}</script><form runat=server> <center><b><u> DataBinding</center></b></u><br> Enter a string and press tab <br><br> Exploring ASP.NET / Session 13 / 6 of 31Simple Properties<asp:textbox id = "txtControl" AutoPostback="true" runat= "server" /><br> <br><asp:label id = "lblControl" text = <%#txtControl.Text%> runat = "server" /><br><br></form></html> Exploring ASP.NET / Session 13 / 7 of 31Expressions and Methods<%@ Import Namespace="System.Data" %><html><title>DataBinding Expressions</title><script language="C#" runat="server">void Page_Load(Object Sender, EventArgs E) { Response.Write("<center><b><u>DataBinding Expressions</center></b></u><br>"); if(!IsPostBack) {DataTable mydt = new DataTable();DataRow mydr; mydt.Columns.Add(new DataColumn ("Numbers", typeof(Int32))); Exploring ASP.NET / Session 13 / 8 of 31Expressions and Methodsfor (int i=0;i<=5;i++){mydr = mydt.NewRow();mydr[0] = i;mydt.Rows.Add(mydr);} dlMyList.DataSource = mydt; dlMyList.DataBind(); } } int Square(int num) {int ans = num* num;return ans; } Exploring ASP.NET / Session 13 / 9 of 31Expressions and Methods int Cube(int num) {int ans = num*num*num;return ans; } </script> <form runat=server> <asp:DataList id = "dlMyList" runat = "server"> <ItemTemplate>Number : <%# ((DataRowView)Container.DataItem)["Numbers"] %>Square : <%# Square ((int) ((DataRowView) Container.DataItem) ["Numbers"]) %>Cube : <%# Cube ((int) ((DataRowView) Container.DataItem) ["Numbers"]) %> Exploring ASP.NET / Session 13 / 10 of 31Expressions and Methods</ItemTemplate></asp:DataList></form></html> [...]... %> Exploring ASP.NET / Session 13 / 22 of 31 DataList Output Exploring ASP.NET / Session 13 / 23 of 31 Data Handling in ASP.NET Insert Update DATA Delete Select Exploring ASP.NET / Session 13 / 24 of 31 Inserting Data To insert data: 1 Connect to Database 2 Create... Exploring ASP.NET / Session 13 / 17 of 31 Repeater Output Exploring ASP.NET / Session 13 / 18 of 31 DataList The DataList control allows the users to specify the flow of data ItemTemplate T e m p l a t e s AlternatingItemTemplate SelectedItemTemplate EditItemTemplate HeaderTemplate FooterTemplate SeparatorTemplate Exploring ASP.NET / Session 13 / 19 of 31... Exploring ASP.NET / Session 13 / 15 of 31 Repeater Example Exploring ASP.NET / Session... Exploring ASP.NET / Session 13 / 11 of 31 Repeater The Repeater control is a container control, which can be used to display a list of data repeating a specified template for each item A template is a set of HTML elements and controls that can be used to format the layout of a control T e m p l a t e s ItemTemplate AlternatingItemTemplate HeaderTemplate FooterTemplate SeparatorTemplate Exploring ASP.NET. .. typeof(Int32))); Exploring ASP.NET / Session 13 / 20 of 31 DataList Example mydt.Columns.Add(new DataColumn("Squares", typeof(Int32))); mydt.Columns.Add(new DataColumn("Cubes",typeof(Int32))); for (int i=0;i . Session 13ADO .NET - II Exploring ASP. NET / Session 13 / 2 of 31ReviewADO .NET possesses two core components:DataSet and .NET Data Provider The. %> Exploring ASP. NET / Session 13 / 10 of 31Expressions and Methods</ItemTemplate>< /asp: DataList></form></html> Exploring ASP. NET / Session