Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have id and name textboxes in my project.

If I search all customer by id, it shows 34 records in 3 pages and if I view 3rd page in data pager and if I need to search all customer by name it shows 30 records in 2 page.

It shows the 2nd page of current record instead of 1st page, because the previous record I viewed was the 3rd page so it take the last page in current record.

How can I solve this problem?
Posted
Updated 15-Dec-11 22:11pm
v3
Comments
Dalek Dave 16-Dec-11 4:11am    
Edited for Grammar and Readability.

try this sample code:


C#
<asp:GridView ID="grid_view" runat="server" AllowPaging="True" 
    AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" 
    BorderStyle="Solid" BorderWidth="1px" CellPadding="3" ForeColor="Black" 
    GridLines="Vertical">
    <FooterStyle BackColor="#CCCCCC" />
    <Columns>
        <asp:BoundField DataField="adc" HeaderText="Posa No." />
        <asp:BoundField DataField="cde" HeaderText="Unit" />
        <asp:BoundField DataField="efg" HeaderText="User" />
        <asp:BoundField DataField="hj" HeaderText="Posa Date" />
    </Columns>
    <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
    <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
    <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" /> 
    <AlternatingRowStyle BackColor="#CCCCCC" />
</asp:GridView>


refer at:
http://stackoverflow.com/questions/6798340/paging-problem-with-gridview
 
Share this answer
 
v3
Comments
Dalek Dave 16-Dec-11 4:11am    
Good Answer.
RempoRaaj 16-Dec-11 23:44pm    
Thanks Dave
Hi,

on click of your search button set
C#
gridView.PageIndex =0;


hope this will help you,

thanks
-amit.
 
Share this answer
 
Comments
priya from Madras 15-Dec-11 9:06am    
pls read my problem again
Finally i got the answer for my problem:


Its Working fine.

Thanks All



ListView1.DataSource = details;
ListView1.DataBind();
int CurrentPage = 0;
int PageSize = DataPagerId.PageSize;
DataPagerId.SetPageProperties(CurrentPage * PageSize, PageSize, true);
 
Share this answer
 
v2
Hi all ,pls give me a solution
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900