locked
How to apply search for this listbox RRS feed

Answers

  • User-719153870 posted

    Hi Gopi.MCA,

    This link i provided is exactly workble in asp.net with listbox, let me show you a demo:

    ASPX:

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.sumoselect/3.0.2/jquery.sumoselect.min.js"></script>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery.sumoselect/3.0.2/sumoselect.min.css" />
        <script>
            $(document).ready(function () {
                $('#ListBox1').SumoSelect({search: true, searchText: 'Enter here.'});
            });
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <asp:ListBox ID="ListBox1" runat="server" selectionmode="Multiple" DataTextField="UName" DataValueField="UID" DataSourceID="SqlDataSource1"></asp:ListBox>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=.;Initial Catalog=DatabaseTestPool;Integrated Security=True" SelectCommand="select UID,UName from Users"></asp:SqlDataSource>
            </div>
        </form>
    </body>
    </html>

    And the result of this demo:

    Hope this can help you.

    Best Regard,

    Yang Shen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 9, 2019 9:07 AM

All replies

  • User-719153870 posted

    Hi Gopi.MCA,

    http://www.codingfusion.com/Post/Dropdownlist-with-checkboxes-in-asp-net

    This 3rd-party jQuery is really not suitable for the search function, you can see this SumoSelect() funciton in this article will make the listbox shown as a <span> instead of a textbox which you can enter words in.

    I tried many ways and found that this function can't be fired twice in your code.

    So, i will suggest you to find another 3rd-party solutions that can make your listbox searchble, like this one is perfect enough.

    As you can see, it has its own search function.

    Best Regard,

    Yang Shen

    Monday, September 9, 2019 6:29 AM
  • User-807418713 posted

    Hello Sir

    Thank You

    Can you give me one example using asp.net listbox so that it would be helpful.

    Thanking You

    Monday, September 9, 2019 7:27 AM
  • User-719153870 posted

    Hi Gopi.MCA,

    This link i provided is exactly workble in asp.net with listbox, let me show you a demo:

    ASPX:

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.sumoselect/3.0.2/jquery.sumoselect.min.js"></script>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery.sumoselect/3.0.2/sumoselect.min.css" />
        <script>
            $(document).ready(function () {
                $('#ListBox1').SumoSelect({search: true, searchText: 'Enter here.'});
            });
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <asp:ListBox ID="ListBox1" runat="server" selectionmode="Multiple" DataTextField="UName" DataValueField="UID" DataSourceID="SqlDataSource1"></asp:ListBox>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=.;Initial Catalog=DatabaseTestPool;Integrated Security=True" SelectCommand="select UID,UName from Users"></asp:SqlDataSource>
            </div>
        </form>
    </body>
    </html>

    And the result of this demo:

    Hope this can help you.

    Best Regard,

    Yang Shen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 9, 2019 9:07 AM
  • User-807418713 posted

    Hello Yang Shen

    Is "Sumoselect This Open Source Free?

    Thanking You

    Monday, September 9, 2019 9:36 AM
  • User-719153870 posted

    Hi Gopi.MCA,

    I believe so, i was never been asked to pay when i built this demo.

    Best Regard,

    Yang Shen

    Monday, September 9, 2019 9:44 AM
  • User-807418713 posted

    Hello

    Can We increase the size of Width For listbox1 it has only small area while displaying the data

    Thanking You

    Monday, September 9, 2019 9:55 AM