设置DropDownList下拉列表的内容

调用:

SetDropDownList(RoomNum, 1, 10, 0);

///


        /// 设置DropDownList下拉列表的内容
        ///

  public static void SetDropDownList(DropDownList xDropDownList,int xMin,int xMax,int xInt)
  {
   xDropDownList.Items.Clear();
   for(int i=xMin;i<=xMax;i++)
   {
    ListItem myItem=new ListItem(i.ToString(),i.ToString());
    xDropDownList.Items.Add(myItem);
   }
   xDropDownList.SelectedIndex=xInt;
  }

转载于:https://www.cnblogs.com/wzg0319/archive/2011/02/15/1955020.html

你可能感兴趣的:(设置DropDownList下拉列表的内容)