aspx dropdownList不保留所选值

问题描述 投票:0回答:1

带有下拉列表的继承代码,用于填充某些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个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.