There are 3 scenarios: 1.Search button------>paging is working 2.View button-------->paging is working 3.Autosearch--------->paging is not working. when i click on search button,results are getting displayed.when i wanted to go to next page.it goes. when i click on view button,results are getting displayed.when i wanted to go to next page.it goes. when i autosearch,results are getting displayed.when i wanted to go to next page.it is not going. why it is happening so?
error which i got during autosearch:
https://ibb.co/nN16M8
//Code for Paging using DataPager
    protected void OnPagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
    {
        (lstvwproposals.FindControl("DataPager1") as DataPager).SetPageProperties(e.StartRowIndex, e.MaximumRows, false);
        
        if (ViewState["selectList"].Equals("Search"))
        {
            bindlistview();
        }
        else if (ViewState["selectList"].Equals("View"))
        {
            Getviewlist();
        }
        else
        {
            //cmdUpdateField_Click();
           // SearchCustomers(prefixText, count);
           
        }
        
        
    }
 
//Search button code
protected void Button2_Click(object sender, EventArgs e)//search button
    {
        bindlistview();
    }
    protected void bindlistview()
    {
        ViewState["selectList"] = "Search";
        string prefixText = txtsearch.Text;
        MySqlConnection connect = null;
        try
        {
            string connStr = ConfigurationManager.ConnectionStrings["BarterConnectionString"].ToString();
            connect = new MySqlConnection(connStr);
            // string queryStr = "select distinct bp.pro_id,bp.user_id,bu.username,bp.sent_date,bw.name,bp.email_id,bc.comp_name,bc.website,bp.contact_name,bp.proposal_status from barter_proposals bp,barter_company bc,barter_websites bw,barter_userlog bu where bp.company=bc.comp_id and bp.website_a=bw.web_id and bp.user_id=bu.user_id and bc.website like '%" + txtsearch.Text + "%' UNION ALL " +
            //"select distinct bp.pro_id,bp.user_id,bu.username,bp.sent_date,bw.name,bp.email_id,bc.comp_name,bc.website,bp.contact_name,bp.proposal_status from barter_proposals bp,barter_company bc,barter_websites bw,barter_service_exchg bsx,barter_ser_links bsl,barter_userlog bu where bsl.serv_id=bsx.exchg_service_id and bsx.proposal_id=bp.pro_id and bp.company=bc.comp_id and bp.user_id=bu.user_id and bp.website_a=bw.web_id and bsl.link like '%" + txtsearch.Text + "%'";
             string queryStr = "select distinct bp.pro_id,bp.user_id,bu.username,bp.sent_date,bw.name,bp.email_id,bc.comp_name,bc.website,bp.contact_name,bp.proposal_status from barter_proposals bp,barter_company bc,barter_websites bw,barter_service_exchg bsx,barter_ser_links bsl,barter_userlog bu where bsl.serv_id=bsx.exchg_service_id and bsx.proposal_id=bp.pro_id and bp.company=bc.comp_id and bp.user_id=bu.user_id and bp.website_a=bw.web_id and (bsl.link like '%" + txtsearch.Text + "%' OR bc.website like '%" + txtsearch.Text + "%')";//commented by chetan
           // string queryStr = "select comp_id, website from barter_company where website like '%' ?SearchText '%' union " +
   // " select bp.company as comp_id,link as website,bp.pro_id from barter_ser_links bsl,barter_service_exchg bse,barter_proposals bp where bse.exchg_service_id=bsl.serv_id and bse.proposal_id=bp.pro_id and bsl.link like '%' ?SearchText '%' ";
            connect.Open();
            MySqlCommand command = new MySqlCommand(queryStr, connect);
           // command.Parameters.AddWithValue("?SearchText", prefixText);//uncommented by chetan
            MySqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
            DataTable dt = new DataTable();
            dt.Load(reader);
            lstvwproposals.DataSource = dt;
            lstvwproposals.DataBind();
            connect.Close();
        }
        catch(Exception ex)
        {
            connect.Close();
        }
    }
 
//View Button Code
	
	 protected void Button3_Click(object sender, EventArgs e)//view button
    {
        Getviewlist();
        ViewState["selectList"] = "View";
    }
    protected void Getviewlist()
    {
        string eventquery = "", compquery = "", comp = "", proquery = "", email = "", emailquery = "", ser_date = "", sentdatequry = "", userquery = "", prostatus = "";
        int eventid = 0, user = 0;
        if (ddlevents.SelectedIndex != 0)
        {
            eventid = Convert.ToInt32(ddlevents.SelectedValue);
            eventquery = " and bea.event_id=?event_id";
        }
        if (txtcomp.Text != "")
        {
            comp = txtcomp.Text;
            compquery = " and bc.comp_name like '%' ?comp '%'";
        }
        if (txtemail.Text != "")
        {
            email = txtemail.Text;
            emailquery = " and bp.email_id like '%' ?emailid '%'";
        }
        if (txtsdate.Text != "")
        {
           
            //DateTime sdate = new DateTime();
            DateTime sdate = Convert.ToDateTime(txtsdate.Text).Date;
           // sdate = DateTime.ParseExact(date, "yyyy-MM-dd", null);
             ser_date = sdate.ToString("yyyy/MM/dd");
            sentdatequry = " and bp.sent_date=?sdate";
        }
        if (ddlpstatus.SelectedIndex != 0)
        {
            prostatus = ddlpstatus.SelectedItem.Text;
            proquery = " and bp.proposal_status=?prostat";
        }
        if (ddlusers.SelectedIndex != 0)
        {
            user = Convert.ToInt32(ddlusers.SelectedValue);
            userquery = " and bp.user_id=?uid";
        }
        MySqlConnection connect = null;
        try
        {
            string connStr = ConfigurationManager.ConnectionStrings["BarterConnectionString"].ToString();
            connect = new MySqlConnection(connStr);
           string queryStr = "select bp.pro_id,bp.sent_date,bw.name,bp.email_id,bc.comp_name,bp.user_id,bc.website,bp.contact_name,bp.proposal_status ,bu.username from barter_proposals bp left join barter_propeventassign bea on  bp.pro_id=bea.prop_id,barter_company bc,barter_websites bw,barter_userlog bu where bp.company=bc.comp_id and bp.website_a=bw.web_id and bp.user_id=bu.user_id " +
            eventquery + compquery + emailquery + sentdatequry + proquery + userquery + " order by bp.pro_id";
            //  string queryStr = "select * from barter_proposals";
            connect.Open();
            MySqlCommand command = new MySqlCommand(queryStr, connect);
            command.Parameters.AddWithValue("?event_id", eventid);
            command.Parameters.AddWithValue("?comp", comp);
            command.Parameters.AddWithValue("?emailid", email);
            command.Parameters.AddWithValue("?sdate", ser_date);
            command.Parameters.AddWithValue("?prostat", prostatus);
            command.Parameters.AddWithValue("?uid", user);
            MySqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
            DataTable dt = new DataTable();
            dt.Load(reader);
            lstvwproposals.DataSource = dt;
            lstvwproposals.DataBind();
            connect.Close();
        }
        catch
        {
            connect.Close();
        }
    }
	
 
//Autosearch code
	
	  [System.Web.Script.Services.ScriptMethod()]
    [System.Web.Services.WebMethod]
    public static List<string> SearchCustomers(string prefixText, int count)
    {
       // ViewState["selectList"] = "AutoSearch";
        MySqlConnection connect = null;
        string connStr = ConfigurationManager.ConnectionStrings["BarterConnectionString"].ToString();
        connect = new MySqlConnection(connStr);
        string queryStr = "select comp_id, website from barter_company where website like '%' ?SearchText '%' union "+
        " select bp.company as comp_id,link as website from barter_ser_links bsl,barter_service_exchg bse,barter_proposals bp where bse.exchg_service_id=bsl.serv_id and bse.proposal_id=bp.pro_id and bsl.link like '%' ?SearchText '%' ";
        connect.Open();
        MySqlCommand command = new MySqlCommand(queryStr, connect);
        command.Parameters.AddWithValue("?SearchText", prefixText);
        MySqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
        DataTable dt = new DataTable();
        dt.Load(reader);
        List<string> customers = new List<string>();
       
         if (dt.Rows.Count > 0)
         {
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 string item = AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(dt.Rows[i]["website"].ToString(), dt.Rows[i]["comp_id"].ToString());
                 //string item =dt.Rows[i]["website"].ToString();
                 customers.Add(item);
                 
                //customers.CssClass += "selected";
             }
         }
         connect.Close();
         return customers;
    }
 
 
<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="Site.master" CodeFile="view_proposals.aspx.cs"
    Inherits="view_proposals" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    <script type="text/javascript">
        function ClientItemSelected(sender, e) {
            $get("<%=hfCustomerId.ClientID %>").value = e.get_value();
            document.getElementById("<%=cmdUpdateField.ClientID%>").click();
        }   
    </script>
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"
        rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
    <script type="text/javascript">
        jQuery.noConflict();
        jQuery(document).ready(function () {
            jQuery(".datepicker").datepicker();
        });
 
 
 
    </script>
    <script type="text/javascript">
        function autoCompleteShow() {
            var elements = document.getElementsByClassName('ulclass');
            for (var i = 0; i < elements.length; i++)
                if (elements[i].innerHTML.search("") != -1)
                    elements[i].style.setProperty("background-color", "#4CC417", "!important");
                else
                    elements[i].style.setProperty("background-color", "Red", "!important");
        }
    </script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <div class="span9">
        <%--<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>--%>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <div class="content">
            <div class="module">
                <div class="module-head">
                    <h3>
                        All proposals</h3>
                </div>
                <div class="module-option clearfix">
                    <div id="ajaxdiv" class="input-append pull-left">
                        <%--<input type="text" class="span3" placeholder="Filter by Company/website...">--%>
                        <asp:TextBox ID="txtsearch" placeholder="Filter by website" Width="300px" AutoComplete="off"
                            runat="server"></asp:TextBox>
                        <cc1:AutoCompleteExtender ServiceMethod="SearchCustomers" OnClientShown="autoCompleteShow"
                            CompletionListCssClass="CompletionListCssClass" CompletionListItemCssClass="ulclass"
                            MinimumPrefixLength="2" CompletionInterval="100" EnableCaching="false" CompletionSetCount="10"
                            TargetControlID="txtsearch" ID="AutoCompleteExtender1" BehaviorID="ajaxid" runat="server"
                            FirstRowSelected="false" OnClientItemSelected="ClientItemSelected">
                        </cc1:AutoCompleteExtender>
                        <asp:HiddenField ID="hfCustomerId" runat="server" />
                           
                        <asp:Button ID="Button2" class="btn" runat="server" Text="Search" OnClick="Button2_Click">
                        </asp:Button>
                    </div>
                    <br />
                    <br />
                    <asp:LinkButton CssClass="dnnPrimaryAction" ID="cmdUpdateField" runat="server" Text=""
                        OnClick="cmdUpdateField_Click"></asp:LinkButton>
                    <div class="panel-group" id="accordion">
                        <div class="panel panel-default" style="margin-left: 20px;">
                            <div class="panel-heading">
                                <h4 class="panel-title">
                                    <a data-toggle="collapse" data-parent="#accordion" href="#collapseThree" align="left">
                                        Advance Search</a>
                                </h4>
                            </div>
                            <div id="collapseThree" class="panel-collapse collapse">
                                <div class="panel-body">
                                    <table class="editable">
                                        <tr>
                                            <td>
                                                Exhibition:<br />
                                                <%--<asp:TextBox ID="txtExhibition" runat="server" Width="207px"></asp:TextBox>--%>
                                                <asp:DropDownList ID="ddlevents" runat="server">
                                                </asp:DropDownList>
                                            </td>
                                            <td>
                                                Company:<br />
                                                <asp:TextBox ID="txtcomp" Width="207px" runat="server"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                email_id:<br />
                                                <asp:TextBox ID="txtemail" Width="207px" runat="server"></asp:TextBox>
                                            </td>
                                            <td>
                                                Proposal Status:<br />
                                                <asp:DropDownList ID="ddlpstatus" runat="server" Width="207px">
                                                    <%-- <asp:ListItem>Select</asp:ListItem>
                                                  <asp:ListItem>Sent/Recieved</asp:ListItem>
                                                   <asp:ListItem>in-progress</asp:ListItem>
                                                    <asp:ListItem>Converted</asp:ListItem>--%>
                                                </asp:DropDownList>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                Sent Date:
                                                <br />
                                                <asp:TextBox ID="txtsdate" class="datepicker" runat="server" Width="207px"></asp:TextBox>
                                            </td>
                                            <td>
                                                User:<br />
                                                <asp:DropDownList ID="ddlusers" runat="server">
                                                </asp:DropDownList>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <asp:Button ID="btnview" class="btn btn-mini btn-info" runat="server" Text="view"
                                                    OnClick="Button3_Click" />
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div>
                        <div>
                            <asp:ListView ID="lstvwproposals" OnPagePropertiesChanging="OnPagePropertiesChanging"
                                OnItemDataBound="ListView1_ItemDataBound" runat="server" DataKeyNames="pro_id">
                                <LayoutTemplate>
                                    <div class="module message">
                                        <div class="module-body table">
                                            <table class="table table-message">
                                                <tbody>
                                                    <tr class="heading">
                                                        <td class="cell-title">
                                                            View
                                                        </td>
                                                        <td class="cell-title">
                                                            Edit
                                                        </td>
                                                        <td class="cell-title">
                                                            sent_date
                                                        </td>
                                                        <%-- <td class="cell-title">Event</td>--%>
                                                        <%--<th  >Website/Directory(a)</th>--%>
                                                        <td class="cell-title">
                                                            User
                                                        </td>
                                                        <%-- <td class="cell-title" >Company</td>  --%>
                                                        <td class="cell-title">
                                                            Website(b)
                                                        </td>
                                                        <td class="cell-title">
                                                            Website(a)
                                                        </td>
                                                        <td class="cell-title">
                                                            Proposal Status
                                                        </td>
                                                    </tr>
                                                    <tr id="itemPlaceholder" runat="server" />
                                                    <tr id="Tr1" runat="server" align="center">
                                                        <td colspan="2" align="left">
                                                            <asp:Label ID="lblCount" runat="server"></asp:Label>
                                                        </td>
                                                        <td id="Td1" runat="server" style="" colspan="4">
                                                            <asp:DataPager class="mpart" ID="DataPager1" PageSize="12" runat="server">
                                                                <Fields>
                                                                    <asp:NumericPagerField ButtonType="Link" ButtonCount="3" PreviousPageText="<<<" NextPageText=">>>" />
                                                                </Fields>
                                                            </asp:DataPager>
                                                        </td>
                                                        <td colspan="2" align="left">
                                                        </td>
                                                    </tr>
                                                    <tbody>
                                            </table>
                                        </div>
                                    </div>
                                </LayoutTemplate>
                                <ItemTemplate>
                                    <tr class="unread">
                                        <td class="command">
                                            <asp:LinkButton ID="HyperLink1" runat="server" OnCommand="getview" Text="view" CommandArgument='<%# Eval("pro_id")%>'
                                                CssClass="linkEditButton" Font-Underline="True" />
                                        </td>
                                        <td class="command">
                                            <asp:LinkButton OnCommand="getedit" ID="btnEdit" runat="server" Text="Edit" CommandArgument='<%# Eval("pro_id")%>'
                                                CssClass="linkEditButton" Font-Underline="True" />
                                        </td>
                                        <td class="cell-title">
                                            <%# Eval("sent_date", "{0:dd-MM-yyyy}")%>
                                        </td>
                                        <%--  <td ><%# Eval("event_name")%></td>--%>
                                        <%--  <td ><%# Eval("name")%></td>--%>
                                        <td class="cell-title">
                                            <%# Eval("username")%>
                                        </td>
                                        <%--<td class="cell-title"><%# Eval("comp_name")%></td>--%>
                                        <td class="cell-title">
                                            <%# Eval("website")%>
                                        </td>
                                        <td class="cell-title">
                                            <%# Eval("name")%>
                                        </td>
                                        <%--<td class="cell-title"><%# Eval("contact_name")%></td>--%>
                                        <td class="cell-title">
                                            <%# Eval("proposal_status")%>
                                        </td>
                                    </tr>
                                </ItemTemplate>
                                <AlternatingItemTemplate>
                                    <tr class="unread">
                                        <td class="command">
                                            <asp:LinkButton ID="HyperLink1" runat="server" OnCommand="getview" Text="view" CommandArgument='<%# Eval("pro_id")%>'
                                                CssClass="linkEditButton" Font-Underline="True" />
                                        </td>
                                        <td class="command">
                                            <asp:LinkButton OnCommand="getedit" ID="btnEdit" CommandArgument='<%# Eval("pro_id")%>'
                                                runat="server" Text="Edit" Font-Underline="True" />
                                        </td>
                                        <td>
                                            <%# Eval("sent_date", "{0:dd-MM-yyyy}")%>
                                        </td>
                                        <%--  <td ><%# Eval("event_name")%></td>--%>
                                        <%-- <td ><%# Eval("name")%></td>--%>
                                        <td class="cell-title">
                                            <%# Eval("username")%>
                                        </td>
                                        <%-- <td class="cell-title"><%# Eval("comp_name")%></td>--%>
                                        <td class="cell-title">
                                            <%# Eval("website")%>
                                        </td>
                                        <td class="cell-title">
                                            <%# Eval("name")%>
                                        </td>
                                        <%--<td class="cell-title"><%# Eval("contact_name")%></td>--%>
                                        <td class="cell-title">
                                            <%# Eval("proposal_status")%>
                                        </td>
                                    </tr>
                                </AlternatingItemTemplate>
                                <EmptyDataTemplate>
                                    <div style="text-align: center; font-weight: bold">
                                        0 Results Founds</div>
                                </EmptyDataTemplate>
                            </asp:ListView>
                            <br />
                        </div>
                    </div>
                    <%-- <asp:Button ID="Button1" class="btn btn-danger" runat="server" Text="Export" />--%>
                </div>
            </div>
        </div>
    </div>
</asp:Content>