0

我有一个updatePanel,它有一个文本框作为内容,一个下拉列表作为触发器。每当我更改下拉列表的selectedIndex时,它都会查询数据库,它会给我一个文本框

现在我输入了一些新,然后单击更新 按钮,它将保存在数据库中。

这里的问题,它一直让我得到旧下拉列表带来的值)。

我怎么能解决这个问题?

编辑

          <asp:UpdatePanel ID="uplKmAllowed" runat="server">
            <ContentTemplate>
                <dx:ASPxTextBox ID="txtKmAllowed" runat="server" Width="215px" OnTextChanged="txtKmAllowed_TextChanged">
                </dx:ASPxTextBox>
            </ContentTemplate>
        </asp:UpdatePanel>

后面的代码:这是以编程方式添加触发器,因为 cboAsset 在用户控件中

   asset = fltrAsset.FindControl("cboAsset") as ASPxComboBox;
asset.AutoPostBack = true;

asset.SelectedIndexChanged += new EventHandler(Asset_SelectIndexChanged); 
        AsyncPostBackTrigger trigger = new AsyncPostBackTrigger();
        trigger.ControlID = asset.UniqueID;
        trigger.EventName = "SelectedIndexChanged";

        uplKmAllowed.Triggers.Add(trigger);

功能

 protected void Asset_SelectIndexChanged(object sender, EventArgs e)
    {
        string tudID = asset.SelectedItem.Value.ToString();
        RentalTracking rtk = new RentalTracking();
        string assetID = rtk.getAssetIDDepartmentIDbyTudID(tudID)[1];
        RentalAssetInfo rai = new RentalAssetInfo();
        rai.GetRentalAssetInfo(Int32.Parse(assetID));
        if (rai.KMAllowed == 0 || rai.KMAllowed == -1 || rai.KMAllowed == null)
        {
            kmallowedSaved = false;
            txtKmAllowed.Text = "";
        }
        else
        {
            txtKmAllowed.Text = rai.KMAllowed.ToString();
        }
    }
4

1 回答 1

-1
use asp:AsyncPostBackTrigger in update panel
  <asp:UpdatePanel ID="uplKmAllowed" runat="server">
            <ContentTemplate>
                <dx:ASPxTextBox ID="txtKmAllowed" runat="server" Width="215px" OnTextChanged="txtKmAllowed_TextChanged">
                </dx:ASPxTextBox>
            </ContentTemplate>
 <Triggers>
            <asp:AsyncPostBackTrigger ControlID="LnkEditBuyingLead" EventName="EventName"/>
        </Triggers>
        </asp:UpdatePanel>
于 2013-10-21T04:36:56.293 回答