asp.netgridviewpaginationpostback

Why does my ASP GridView Paging not work?


I have a fairly simple asp grid view, tied to an object data source. What I want to have is this gridview update on a button click with results that a dynamic depending on the value within a textbox (it's the basis for a search screen).

So far, everything works as such:

ASPX File:

<h3>Search Parameters</h3>
<div>
   Account Name
   <asp:TextBox runat="server" ID="AccountName"></asp:TextBox>
</div>

<asp:Button ID="Search" runat="server" Text="Search" OnClick="Search_Click" />

<asp:GridView runat="server" ID="SearchGrid" DataSourceID="ObjectDataSource1" AutoGenerateColumns="False" Width="100%" AllowPaging="True" CellPadding="4" ForeColor="#333333" GridLines="None" >
   <Columns>
      <asp:BoundField DataField="PartyID" HeaderText="Party ID" SortExpression="PartyID" />
      <asp:BoundField DataField="PartyName" HeaderText="Party Name" SortExpression="PartyName" />
       <asp:BoundField DataField="CompleteAddress" HeaderText="Address" SortExpression="CompleteAddress" />
     </Columns>
     <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
 </asp:GridView>

 <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="DIS.Data.DataSetAccountsTableAdapters.GetAccountsBySearchParametersTableAdapter">
   <SelectParameters>
      <asp:Parameter Name="PartyName" Type="String" />
   </SelectParameters>
</asp:ObjectDataSource>

ASPX.CS File:

protected void Search_Click(object sender, EventArgs e)
{
   ObjectDataSource1.SelectParameters["PartyName"].DefaultValue = AccountName.Text;
 }

At face value, everything works. The user enters text into the account name box, hits search, and the grid view is updated with the appropriate values.

The problem occurs when we get enough row to generate paging. The page links are shown on the GridView, but clicking on them has no effect at all - The values will remain consistently on page 1.

I believe that it may be something to do with the postback when the page link is clicked, but unfortunately my knowledge in this area is not strong enough to actually diagnose what exactly is happening.

Any help would be greatly appreciated Best regards


Solution

  • OK, on further testing it doesn't appear to be a GridView specific issue.

    We aer also using JQuery mobile, and it seems that it's those scripts that are causing the issue. Disabling them removed the problem.