//1.值是text
      string aa=  Request.QueryString["CallReason"].ToString();//获取传值
      if (DropDownList1.Items.Contains(new ListItem(aa)))
      {
          DropDownList1.SelectedValue = aa;//如果存在则等于存在的值
      }
      else
      {
          DropDownList1.Items.Insert(0, new ListItem(aa, ""));//否则新增这个选项并且为选中值
          DropDownList1.DataBind();
      }

        //2.假如值是value
        //那么 int i = comboBox1.Items.IndexOf(value);
        //如果 i>=0则在下拉中,否在不在。

 

相关文章:

  • 2022-02-02
  • 2021-11-18
  • 2021-09-26
  • 2022-12-23
  • 2021-12-29
  • 2021-12-15
  • 2022-01-04
猜你喜欢
  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-10
  • 2022-03-08
  • 2022-02-05
相关资源
相似解决方案