代码之家  ›  专栏  ›  技术社区  ›  Developer

如何在上一页选择的当前窗体中禁用下拉列表值

  •  0
  • Developer  · 技术社区  · 14 年前

    2 回复  |  直到 14 年前
        1
  •  0
  •   Jagmag    14 年前

    如果这不是一个选项:-

    1. 如果在单击“确定”时发布表单,则可以使用PreviousPage检索原始页面的值。请参阅下面的示例。

    我不太清楚你所说的“在previos窗体中禁用所选值并希望显示剩余的正常值”是什么意思,但是一旦你检索到这个值,那么你就可以以任何方式操作当前页面中的数据了。

    DropDownList oldValue = (DropDownList)PreviousPage.FindControl("DropDownOldValue");
    
    oldValue.SelectedValue - should then give you the value selected on the previous page
    
        2
  •  0
  •   Developer    14 年前

        DropDownList oldvalue = (DropDownList)PreviousPage.FindControl("DropDownList1");
        string str = oldvalue.SelectedValue.ToString();
    
        ListItem i = DropDownList1.Items.FindByValue(str);
        i.Attributes.Add("style", "color:gray;");
        i.Attributes.Add("disabled", "true");