How to set the default value of a Ajax combobox with a datasource to Null (empty)?

Posted on 2009-12-27
Last Modified: 2012-05-08
Can somebody help me with the following problem?

I've Ajax combobox in mij aspx page wich is filled by a Datasource. But when i run this page I get default a value from the datesource.

I'll have only a empty Combobox at the begin.

This is my combobox and datasource.

            ID="cboStocknumber" runat="server" 

            AutoCompleteMode="SuggestAppend" DataSourceID="StocknumberDS" 

            DataTextField="StockNumber" DataValueField="StockNumber" MaxLength="0" 

            style="display: inline;" Width="200px">


<asp:SqlDataSource ID="StocknumberDS" runat="server" 

            ConnectionString="<%$ ConnectionStrings:CWSConnectionString %>" 


            SelectCommand="SELECT [CustomerID], [StockNumber] FROM [CustomerStockNumber] WHERE ([CustomerID] = @CustomerID)">


                <asp:ControlParameter ControlID="cboCustomer" Name="CustomerID" 

                    PropertyName="SelectedValue" Type="Int32" />



Open in new window

Question by:prinsbj
    1 Comment
    LVL 21

    Accepted Solution

    How about inserting the default item from codebehind something like

    cboStocknumber.Items.Insert(0, new ListItem("Select", "0"));

    I do not have VS at present do could not test it. I am sorry for that.

    Thanks and regards,

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now