设置DropDownList的当前选项

2019-05-12 08:56:09刘景俊

                                        </asp:DropDownList>
______________________________________________________________________________________________
答4:
DropDownList.Items.FindByText("你的值").Selected=true;
DropDownList.Items.FindByValue("你的值").Selected=true;
______________________________________________________________________________________________
答5:
DropDownList1.SelectedIndex=-1;
DropDownList1.Items.FindByText("选定项目的值").Selected=true;

or


DropDownList1.SelectedIndex=-1;
DropDownList1.Items.FindByValue("选定项目的值").Selected=true;
______________________________________________________________________________________________
答6:
我有一办法,从数据库检取,这个是radioButtonList,需要使用哈希表,你可以参考一下
using System.Web.SessionState;

public class modrole : System.Web.UI.Page
    {
 public Hashtable StateIndex;
private void Page_Load(object sender, System.EventArgs e)
        {   
            StateIndex = new Hashtable();                        
            myConnection = new OleDbConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
            if (!IsPostBack)                  
                BindGrid(); 
        }


//数据绑定
        public void BindGrid()
        {   
            OleDbDataReader myReader;  
            String sql = "select * from tb_role order by roleid";
            OleDbDataAdapter myCommand = new OleDbDataAdapter(sql, myConnection);                        
            DataSet ds = new DataSet();