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?
Grab the text of the selected item with:
DDL1.SelectedItem.Text
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With