Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the methods of data binding for DropDownList drop-down box list controls in ASP.NET

Shulou Source: shulou.com Published: 2022-06-03 12:57:10 10月27日 Update

This article mainly shows you the "ASP.NET DropDownList drop-down box list control what are the methods to bind data", the content is easy to understand, well-organized, hope to help you solve your doubts, the following let the editor lead you to study and learn about "ASP.NET DropDownList drop-down box list control in the way to bind data" this article.

The DropDownList Web server control enables the user to select an item from a predefined list. It differs from the ListBox Web server control in that its item list is hidden until the user clicks the drop-down button. In addition, the DropDownList control differs from the ListBox control in that it does not support multiple selection mode.

The rendering of DropDownList in html corresponds to select, so let's take a look at several ways in which DropDownList binds data.

First, bind the Array array to DropDownList

String [] Month = new string [7] {"January", "February", "March", "April", "May", "June", "July"}; this.DropDownList1.DataSource = Month;this.DropDownList1.DataBind ()

This method can bind only one set of data to DropDownList, because DropDownList can bind two kinds of data: 1 is DataTextField and 2 is DataValueField, so the value of DataTextField after the first method is bound = = DataTextField value.

Bind the dynamic Array array to DropDownList

ArrayList ar = new ArrayList (); for (int I = 1; I

Tags: Data methods controls drop-down properties differences content arrays articles one line code dynamics variables benefits servers users learning help services selection Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Shulou Technology Huawei Docker vpn