It is now am, there is no way, now only this time can have spare time to write these articles, I hope this series of articles can help more people. this section focuses on DataBind, which is very important in ASP.net. Almost all controls need it to control data operations. It can also be said to be the data core of ASP.net.
Let's look at a simple example:
<% @ Page Language = "C #" %>
<% @ Import Namespace = "System. Data" %>
<Script Language = "C #" Runat = "Server">
Public void Page_Load (Object src, EventArgs e)
{
// Create an array first
ArrayList arr = new ArrayList ();
Arr. Add ("Flying knife ");
Arr. Add ("Zsir ");
Arr. Add ("Strong Wind ");
Arr. Add ("pudding ");
Arr. Add ("yahao ");
// Bind the array to the DropDownList control.
DDL. DataSource = arr;
DDL. DataBind ();
}
</Script>
<Html>
<Head>
<Title> </title>
</Head>
<Body>
<Asp: DropDownList id = "DDL" runat = "server"/>
</Body>
</Html>
The last display is:
Flying knife Zsir Gale pudding yahao
We can see in the code that we have created a DropDownList, but it does not have the <asp: ListItem> attribute, and we can still see the options we listed from the final display.
Here is the result of using DataBind. In the Page_Load method, we create an array (ArrayList) and bind the array to the DropDownList control using the DataBind method, so that the DropDownList has data display at the end :). How can I get a certain understanding of Bind. Next we will start to explain