Close contact with ASP.net (5)

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.