Aspnet后台设置DropDownList的选中项

作者:陆金龙    发表时间:2014-12-11 23:54   


   //如果DropDownList1的Text和Value值一致
   this.DropDownList1.SelectedIndex= this.DropDownList1.Items.IndexOf(new ListItem(指定项));
   
   //如果Text和Value值不一致   
   this.DropDownList1.SelectedIndex= this.DropDownList1.Items.IndexOf(this.DropDownList1.Items.FindByText(指定项));//指定Text值
   this.DropDownList1.SelectedIndex= this.DropDownList1.Items.IndexOf(this.DropDownList1.Items.FindByValue(指定项));//指定Value值