【问题标题】:aspx dropdownList does not maintain selected valueaspx dropdownList 不维护所选值
【发布时间】:2020-06-02 21:43:48
【问题描述】:

带有下拉列表的继承代码,用于填充某些 GridView。在下拉列表中进行选择时,选择不会保留,它会跳回到第一条记录。经常提到的解决方法是在 Page_Load 事件中添加 !Page.IsPostBack,但是这样做并不能解决问题。

<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="true" 
   DataSourceID="SqlDataSource2" DataTextField="FullAddress" 
    DataValueField="UniqueRecordID" Width="445px" Height="20px" 
    style="margin-left: 0px" TabIndex="8" AppendDataBoundItems="true"
    OnSelectedIndexChanged="resetGridsAndLabel">
</asp:DropDownList>

 public partial class _Default : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        if (!Page.IsPostBack)
        {
            DropDownList2.DataSource = sqlDataSource2;
            DropDownList2.DataBind();
        }

【问题讨论】:

    标签: asp.net postback


    【解决方案1】:

    您是否在页面的其他任何位置设置 DDL 的数据源?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-27
      相关资源
      最近更新 更多