我需要在代码中读取嵌套在FormView中的下拉列表(dropdownlist)的dataTextField所选文本(而非值)。
以下是我的DDL:
<asp:DropDownList ID="DDL1" runat="server" DataSourceID="SQL1" dataTextField="name" DataValueField="IDname" CausesValidation="True" ClientIDMode="Static">
</asp:DropDownList>
这是我的后台代码:
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?
}
到目前为止,一切都还不错。现在我想获取与所选值对应的dataTextField中的文本。这可能吗?如何实现?