我正在使用以下代码在我的 aspx 页面中显示下拉列表,并且下拉列表中加载的数据是由 SqlDatasource4
<asp:DropDownList ID="DropDownListnew" runat="server"
CssClass="ddlb" Width="210px" Height="30px" DataSourceID="SqlDataSource4"
DataTextField="OrderPeriod" DataValueField="OrderPeriodID">
</asp:DropDownList>
当我尝试通过以下代码访问我的 C#
文件中的下拉列表数据时:
string data = DropDownListnew.Text;
它打印所选值的编号,我想将所选值存储在数据字符串中。我应该怎么做?
最佳答案
您可以通过;
string data = DropDownListnew.SelectedValue; // property not .Text property
关于c# - 如何从 aspx 下拉列表中获取选定的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12097639/