当我从下拉列表中选择我的组并单击按钮时,我有 asp.net 页面下拉列表和按钮,然后按钮通过查询字符串发送选定的值(组 ID)然后基于查询字符串中的 ID 的页面查看组详细信息,这是第一次发生但是当我从下拉列表更改组查询字符串仍然具有最后一个 id 和我的代码
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack) FillList();
if (Request.QueryString["id"] != null)
{
FillData();
div_General.Visible = true;
div_Special.Visible = true;
dropdownlist1 .SelectedValue = Request.QueryString["id"];
}
}
protected void button1_Click(object sender, EventArgs e)
{
if (dropdownlist1 .SelectedIndex == 0)
{
par_ErrorMessage.InnerText = "choose group first ...";
par_ErrorMessage.Visible = true;
}
else Response.Redirect("Authority.aspx?id=" + dropdownlist1.SelectedValue);
}
当我单击按钮并假设下拉列表页面生命周期中的新值首先进入页面加载并在此代码中时,我发现了这个问题
dropdownlist1 .SelectedValue = Request.QueryString["id"];
在从 button1_click 读取之前将所选值返回到最后一个
我的 FillList 方法
private void FillList()
{
oGroup = new Cls_Groups();
cmb_Group.DataSource = oGroup.LoadGroups();
cmb_Group.DataBind();
cmb_Group.Items.Insert(0, "-- اختر مما يلي --");
}
拜托,我需要帮助