DropDownList:
<Select...> in the Form element corresponding to DropDownList, we have two ways to define it.
<Asp: DropDownList id = "dropdownlist1" runat = "server">
<Asp: ListItem> Item 1 </asp: ListItem>
<Asp: ListItem> Item 2 </asp: ListItem>
<Asp: ListItem> Item 3 </asp: ListItem>
<Asp: ListItem> Item 4 </asp: ListItem>
</Asp: DropDownList>
Code definition method:
DropDownList dropdownlist1 = new DropDownList ();
The key features are as follows:
The SelectedItem attribute is a ListItem Class. Next we will explain this ListItem attribute.
ListItem attribute,
Because we are most concerned about DropDownList, we will get the result after selecting DropDownList.
Therefore, the attributes that we are most concerned about ListItem are the Text and Value attributes.
Text is the result of the ListItem display on the External table.
Value is the real Value of the selected Item.
To sum up, let's summarize the usage of the SelectedItem attribute of DropDownList.
Dropdownlist1.SelectedItem. Text and dropdownlist1.SelectedItem. Value