locked
AJAX COMBOBOX APPENDS TEXTBOX VALUE TO DROPDOWNLIST ON POSTBACK RRS feed

  • Question

  • User1343581070 posted

    Hi,

           I am using the Ajax Combobox in vs2012 to enter Product Names.  On entering the data and pressing the submit button , if there is an error I display the message and the focus is set to the combobox. However now the Product Name is added to the list even though i havent saved it to database because of the error. I want to display only those items which are in the database

    My html is

    <ajaxToolkit:ComboBox ID="ajxCbxProdName" DataSourceID="SqlDataSource1" RenderMode="Block" CssClass="txtBoxClass1 WindowsStyle" AutoCompleteMode="SuggestAppend" runat="server" DataTextField="PRODUCT_NAME" DataValueField="ID" MaxLength="0" AppendDataBoundItems="true" DropDownStyle="Simple">

    </ajaxToolkit:ComboBox>

    <asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString='<%$ ConnectionStrings:conString %>' SelectCommand="SELECT [PRODUCT_NAME], [ID] FROM [PRODUCT_MAST] WHERE PRODUCT_TYPE='RM' ORDER BY [PRODUCT_NAME]"></asp:SqlDataSource>

     Please help

    regards

    Sanjish

        

    Friday, February 2, 2018 6:42 AM

All replies

  • User2103319870 posted

    <ajaxToolkit:ComboBox ID="ajxCbxProdName" DataSourceID="SqlDataSource1" RenderMode="Block" CssClass="txtBoxClass1 WindowsStyle" AutoCompleteMode="SuggestAppend" runat="server" DataTextField="PRODUCT_NAME" DataValueField="ID" MaxLength="0" AppendDataBoundItems="true" DropDownStyle="Simple">

    </ajaxToolkit:ComboBox>

    You have set the  DropdownStyle to Simple, to resolve the issue you need to change the value to Dropdownlist.

     <ajaxToolkit:ComboBox ID="ajxCbxProdName" DataSourceID="SqlDataSource1" RenderMode="Block" CssClass="txtBoxClass1 WindowsStyle" AutoCompleteMode="SuggestAppend" 
                runat="server" DataTextField="PRODUCT_NAME" DataValueField="ID" MaxLength="0" AppendDataBoundItems="true" DropDownStyle="DropDownList">
            </ajaxToolkit:ComboBox>

    Friday, February 2, 2018 5:58 PM
  • User1343581070 posted

    Hi,

           I have used dropdownstyle as simple so that i can edit the combobox as well. Dropdownlist will not allow me to edit

    Regards

    Sanjish

    Saturday, February 3, 2018 5:17 AM
  • User-166373564 posted

    Hi Sanjish

    To resolve the issue you can change the value to Dropdown. 

    <ajaxToolkit:ComboBox ID="ajxCbxProdName" DataSourceID="SqlDataSource1" RenderMode="Block" 
    CssClass="txtBoxClass1 WindowsStyle" AutoCompleteMode="SuggestAppend" runat="server" 
    DataTextField="PRODUCT_NAME" DataValueField="ID" MaxLength="0" AppendDataBoundItems="true" 
    DropDownStyle="DropDown">

    Regards,

    Angie 

    Wednesday, February 28, 2018 9:57 AM