在WebForm1.aspx中有个DropDownList,现在想在Class1.cs中来调用DropDownList值,如何做.
例如:string StrConn=System.Configuration.ConfigurationSettings.AppSettings["xxx"].ToString().Trim()中的xxx值是DropDownList所选择的值.大家注意了,在Class1.cs中好象没有Session对象的哦.很多人都想用Session.大家可以试试.

解决方案 »

  1.   

    DropDownList1.SelectedIndex=DropDownList1.Items.IndexOf(DropDownList1.Items.FindByText(System.Configuration.ConfigurationSettings.AppSettings["xxx"].ToString().Trim()));
      

  2.   

    调用DropDownList中的值可以用SelectIndexChanged事件,你可以在这个方法中调用class1处理
    private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
    {
    DropDownList sd=(DropDownList)sender;
    string str=sd.SelectedValue.ToString();
    string StrConn=System.Configuration.ConfigurationSettings.AppSettings[str].ToString().Trim();
    //其他代码
    }