I need to read in the code behind the selected text (not the value) in the dataTextField of a dropdownlist that is nested in a FormView.
Here is my DDL:
<asp:DropDownList ID="DDL1" runat="server" DataSourceID="SQL1" dataTextField="name" DataValueField="IDname" CausesValidation="True" ClientIDMode="Static">
</asp:DropDownList>
And here is my code behind:
protected void UpdateButton_Click(object sender, EventArgs e)
{
DropDownList DDL1 = FV1.FindControl("DDL1") as DropDownList;
SQL3.UpdateParameters["ddlparam"].DefaultValue = DDL1.SelectedValue;
// Possible to get the text corresponding to the selectedValue?
}
So far so good. Now I want to get the text in the dataTextField corresponding to the selected value. Possible? and How?
通过以下方式获取所选项目的文本:
DDL1.SelectedItem.Text
您正在寻找DDL.SelectedItem.Text
MSDN
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.