沒有,WEBControl沒有~~~~,如果想有,就自己寫控件了...

解决方案 »

  1.   

    我有现成的控件,要就找我[email protected]
      

  2.   

    items属性
    自己往里填,
    还有就是写代码。
    ^_^
      

  3.   

    namespace WebControlLibrary
    {
    /// <summary>
    /// WebCustomControl1 的摘要说明。
    /// </summary>
    [DefaultProperty("Text"),
    ToolboxData("<{0}:ComboBox runat=server></{0}:ComboBox>")]
    [
    Designer(typeof(WebControlLibrary.ComboBoxDesigner)),
    ValidationProperty("Text"),
    ]
    public class ComboBox : System.Web.UI.WebControls.ListControl, IPostBackDataHandler, INamingContainer 
    { /// <summary>
    /// Creates a new instance of the ComboBox control.
    /// </summary>
    public ComboBox() : base() {}
            
    #region Events
    /// <summary>
    /// The event which occurs when the <see cref="Text"/> property is changed.
    /// </summary>
    public event EventHandler TextChanged;
    /// <summary>
    /// Raises the <see cref="TextChanged"/> event.
    /// </summary>
    /// <param name="e">The data for the event.</param>
    protected virtual void OnTextChanged( EventArgs e ) 
    {
    if ( TextChanged != null ) 
    {
    TextChanged( this, e );
    }
    }
    #endregion #region Implementation of IPostBackDataHandler
    void IPostBackDataHandler.RaisePostDataChangedEvent() 
    {
    OnSelectedIndexChanged(System.EventArgs.Empty);
    } bool IPostBackDataHandler.LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection) 
    {
    // No need to check for the text portion changing. That is handled automagically bool listIndexChanged = false;
        
    if( TextIsInList ) 
    {
            
    ListItem selectedItem = this.Items.FindByText(text.Text);
    Int32 selectedIndex = Items.IndexOf( selectedItem );
                
    if ( this.SelectedIndex != selectedIndex ) 
    {
    listIndexChanged = true;
    this.SelectedIndex = selectedIndex;
    }

    else 
    {
    if ( this.SelectedIndex != -1  ) 
    {
    listIndexChanged = true;
    this.SelectedIndex = -1;
    }
    }
    isLoaded = true;
    return listIndexChanged;
    }
    #endregion
      

  4.   

    #region New Properties
    /// <summary>
    /// Gets or sets the number of rows displayed in the dropdown portion of the <see cref="ComboBox"/> control.
    /// </summary>
    /// <value>
    /// The number of rows displayed in the <see cref="ComboBox"/> control. The default value is 4.
    /// </value>
    [
    Description("Gets or sets the number of rows of the dropdown portion of the ComboBox control."),
    Category("Appearance"),
    DefaultValue(4),
    Bindable(true),
    ]
    public virtual Int32 Rows 
    {
    get 
    {
    object savedRows; savedRows = this.ViewState["Rows"];
    if (savedRows != null)
    return (Int32) savedRows;
    return 4;
    }
    set 
    {
    if ( value < 1 ) 
    {
    throw new ArgumentOutOfRangeException();
    }
    this.ViewState["Rows"] = value;
    } } /// <summary>
    /// Gets or sets the text content of the text box portion of the <see cref="ComboBox"/> control.
    /// </summary>
    [
    Description("Gets or sets the text content of the text box portion of the ComboBox control."),
    Category("Appearance"),
    Bindable(true),
    DefaultValue("")
    ]
    public virtual String Text 
    {
    get 
    {
    this.EnsureChildControls();
    if ( text.Text == null ) 
    {
    return String.Empty;
    }
    return text.Text;
    }
    set 
    {
    this.EnsureChildControls();
    text.Text = value;
    }
    } /// <summary>
    /// Gets a boolean value indicating whether the string in the text portion of the <see cref="ComboBox"/>
    /// can be found in the text property of any of the ListItems in the Items collection.
    /// </summary>
    [
    Browsable(false),
    DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
    ]
    public virtual bool TextIsInList 
    {
    get 
    {
    this.EnsureChildControls();
    return ( Items.FindByText( text.Text ) != null );
    }
    }
        
    /// <summary>
    /// Gets a boolean value indicating whether an external script library should be used,
    /// instead of the library being emitted as a whole.
    /// </summary>
    protected virtual bool UseReferenceLibrary 
    {
    get 
    {
    return ( ReferenceLibraryUrl != String.Empty );
    }
    }
        
    /// <summary>
    /// Queries the web.config file to get the external reference script library path, if available.
    /// </summary>
    protected virtual String ReferenceLibraryUrl 
    {
    get 
    {
    NameValueCollection config = ConfigurationSettings.GetConfig("WebControlLibrary.ComboBox") as NameValueCollection;
    if( config != null ) 
    {
    return config["ReferenceLibraryUrl"];
    }
    return String.Empty;
    }
    }
         #endregion