began to think that asp:dropdownlist data binding if the DataTable type, when writing did not notice, it was written list<t> bound to the DropDownList, As a result, the data can also be bound by setting the DataValueField and DataTextField properties on the corresponding columns.
The process of binding is posted below:
Background code:
protected void Page_Load (object sender, EventArgs e)
{
if (! IsPostBack)
{
This.name2.DataSource = data source;
This.name2.DataValueField = "column name";
This.name2.DataTextField = "column name";
This.name2.DataBind ();
}
}
public void Name2_changed (object sender, EventArgs e)
{
Code implementation with option change
Gets the current option value of the string df = This.name2.SelectedValue;
}
Front Code:
<asp:dropdownlist runat= "Server" id= "name2" onselectedindexchanged= "name2_changed" ></asp:dropdownlist >
Asp:dropdownlist Data Binding