简体   繁体   中英

Set Item limit to be display in ajaxToolkit ComboBox or set the Combobox position downwards in asp.net

I have a ajaxtoolkit combobox inside a gridview and it works perfectly, but the problem is when I click the dropdown button the list overlaps the page so I want to limit the number to be displayed to 10 items per scroll. Next problem is when I try to add an update panel to the page, It destroys the rendering of the combobox. How can I solve this? Thanks in advance

here is my code for the combobox inside the gridview

      <asp:GridView CssClass="pad" ID="dgvOrder" runat="server" BorderStyle="Double" AutoGenerateColumns="False" OnRowDataBound="dgvOrder_RowDataBound" OnRowDeleting="dgvOrder_RowDeleting" HorizontalAlign="Center" >
        <Columns>
        <asp:TemplateField HeaderText="No." AccessibleHeaderText="No.">
                    <ItemTemplate>
                        <%# Container.DataItemIndex + 1 %>
                    </ItemTemplate>
                </asp:TemplateField>
            <asp:TemplateField HeaderText ="Description" AccessibleHeaderText="Description">
                           <ItemTemplate >
                            <ajaxToolkit:ComboBox ID="ddlItems" AutoPostBack="True" AppendDataBoundItems="True" onmouseover="this.size=4;" onmouseout="this.size=1;" DataTextField="item_desc" DataValueField="item_id"  runat="server" AutoCompleteMode="Suggest" ItemInsertLocation="Prepend" OnSelectedIndexChanged="ddlItems_SelectedIndexChanged" DropDownStyle="DropDown" BorderStyle="Double" ></ajaxToolkit:ComboBox> <br />
                             <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Please pick an item" ControlToValidate="ddlItems"></asp:RequiredFieldValidator> 
                           </ItemTemplate>
                           </asp:TemplateField>
            <asp:TemplateField AccessibleHeaderText="Inventory Code" HeaderText="Inventory Code">
                <ItemTemplate>
                 <asp:Label ID="lblInvCode" runat="server" Text=""></asp:Label>
                    </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField AccessibleHeaderText="Qty" HeaderText="Qty">
                <ItemTemplate>
             <asp:TextBox ID="txtQty" runat="server" OnTextChanged="txtQty_TextChanged" AutoPostBack="True" onkeyup ="ValidateText(this);"></asp:TextBox><br />       
             <asp:RequiredFieldValidator ID="RequiredFieldValidator23" runat="server" ErrorMessage="Please input qty" ControlToValidate="txtQty"></asp:RequiredFieldValidator> 
                </ItemTemplate>
            </asp:TemplateField>
             <asp:TemplateField AccessibleHeaderText="UOM" HeaderText="UOM">
                <ItemTemplate>
                    <asp:Label ID="lblUOM" runat="server" Text=""></asp:Label>
                    </ItemTemplate>
            </asp:TemplateField>
             <asp:TemplateField AccessibleHeaderText="SOQ" HeaderText="SOQ">
                <ItemTemplate>
                    <asp:Label ID="lblSOQ" runat="server" Text=""></asp:Label>
                    </ItemTemplate>
            </asp:TemplateField>
              <asp:TemplateField AccessibleHeaderText="Reason" HeaderText="Reason">
                <ItemTemplate>
                    <asp:TextBox ID="txtReason" runat="server" Enabled="False"></asp:TextBox>
                    </ItemTemplate>
            </asp:TemplateField>
            <asp:CommandField ShowDeleteButton="True" />

            </Columns>
    </asp:GridView> 

and here is my code for the updatepanel

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>

</ContentTemplate>
    <Triggers>
  (whole page inside)
    <asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
    <asp:AsyncPostBackTrigger ControlID="txtIdNo" EventName="TextChanged" />
    </Triggers>
    </asp:UpdatePanel>

Long Item Lists / Multiple Input Controls

All of the items in a ComboBox's list will be rendered to the web page it exists in. The AutoCompleteExtender, on the other hand, retrieves items from its ServiceMethod after the page is rendered. When your ComboBox contains a rather long list of items, or when you have a relatively large number of ComboBoxes on the same page (or within the same UpdatePanel), load times could be slowed down significantly. When ComboBoxes perform slowly because of the amount of markup they must render to the browser, an AutoCompleteExtender can be used instead to increase performance.

<ajaxToolkit:ComboBox ID="ComboBox1" runat="server" 
DropDownStyle="DropDown" 
AutoCompleteMode="None"
CaseSensitive="false"
RenderMode="Inline"
ItemInsertLocation="Append"
ListItemHoverCssClass="ComboBoxListItemHover"
  <asp:ListItem>...</asp:ListIem>
  ...

For more information your can look it in this link .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM