gpt4 book ai didi

c# - 数据未通过回发加载到页面加载中

转载 作者:太空宇宙 更新时间:2023-11-03 14:59:07 24 4
gpt4 key购买 nike

我有一个问题。页面加载后数据未加载。我必须在下拉列表中选择一个项目才能加载。在我选择下拉列表中的任何项目之前,我需要加载它。

这是我的代码。

 protected void ddlPeriodStamp_SelectedIndexChanged(object sender, System.EventArgs e)
{
string selectedGroup = string.Empty;
DropDownList ddlItemGroup = (DropDownList)sender;

if (ddlItemGroup.SelectedValue != null)

TreatmentGroup = ddlItemGroup.SelectedValue;
ApplyGridFilter(ddlItemGroup.SelectedValue);


}

protected void ApplyGridFilter(string TreatmentGroup)
{
string selectedGroup = string.Empty;
DBDataSource1.State.BusinessObject.DataPump.FormFilters.Clear();
DBDataSource1.State.BusinessObject.DataPump.FormFilters.Add("TreatmentGroup", TreatmentGroup);
DBDataSource1.State.BusinessObject.Fill(null);
MedicalSchemeDetailGrid.DataBind();
}
protected void Page_LoadComplete(object sender, System.EventArgs e)
{

if (!this.IsPostBack)
ApplyGridFilter(string.Empty);
}

最佳答案

ispostBack 为 false 时调用 ApplyGridFilter(string.Empty); 并在 ispostBack 时调用 ApplyGridFilter(ddlItemGroup.SelectedValue); 为真

protected void Page_LoadComplete(object sender, System.EventArgs e)
{

if (this.IsPostBack)
{
ApplyGridFilter(ddlItemGroup.SelectedValue);// it will hit on first time page load
}
else
{
ApplyGridFilter(string.Empty);// it will hit while you change the dropdown items, But you should set true for **IsAutoPostBack** property on dropsownlist.
}
}

关于c# - 数据未通过回发加载到页面加载中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47197355/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com