Author: Flying
This section is mainly to speak DataBind, this is very important in ASP.NET, almost all controls require it to control data. It can also be said to be the data core of ASP.NET. Let's first look at a simple example:
<% @ Page language = "c #"%>
<% @ Import namespace = "system.data"%>
Public void Page_Load (Object SRC, Eventargs E)
{
// Build an array first
ArrayList arr = new arraylist ();
Arr.add ("flying knife");
Arr.Add ("ZSIR");
Arr.add ("wind");
Arr.Add ("Pudding");
Arr.Add ("Yahao");
// Bundle the array to the DropDownList control
DDL.DataSource = Arr;
DDL.DATABIND ();
}
script>
hEAD>
body>
html>
The final display is:
Flying knife zsir big wind Pudding Yahao
We can see that we have established a DropDownList in your code, but he doesn't have the
Here is what we use DATABIND. In the Page_Load method, we have established an array (arraylist), and bundled this array to the DROPDOWNLIST control via the DATABIND method, making the DropDownList finally displayed :), how to have a sense of feeling for bind Let it know. Below we start formal explanation
In fact, Database, not only bundle the control, but also bundle the properties and methods of the page, even the entire page can be bundled. For example, calling the page.database () method or use Database directly, then the entire page will be bundled, all the data is fully monitored. In the following example, we will use the Database method to bundle DropDownList and get the data.
<% @ Page language = "c #"%>
<% @ Import namespace = "system.data"%>
Public Void Sub_Click (Object Sender, Eventargs E)
{
Page.DATABIND ();
}
script>
hEAD>