i have a gridview in my page and 4 imagebuttons (First, Previous, Next, Last) which seems to don't work perfectly( when i click for example next imagebutton it shows me the message "no records was found")
this the begining tags o my gridview:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="UserID"
AllowPaging="true" AllowSorting="true" EmptyDataText="No record was found" CellPadding="4"
ForeColor="#333333" GridLines="None" PageSize="3">
<PagerSettings Visible="false" />
and these are my imagebuttons
<asp:Label ID="Label1" runat="server" BackColor="#FF8080" Text="Record Not Found"
Visible="False" Width="279px"></asp:Label>
<asp:ImageButton ID="ImageButton1" PostBackUrl="~/gridview.aspx" ImageUrl="~/images/ico_precedant.jpg"
OnClick="imgPageFirst_Command" runat="server" />
<asp:ImageButton ID="ImageButton2" PostBackUrl="~/gridview.aspx" ImageUrl="~/images/Arrow Left.bmp"
OnClick="imgPagePrevious_Command" runat="server" />
<asp:ImageButton ID="ImageButton3" PostBackUrl="~/gridview.aspx" ImageUrl="~/images/Arrow Right.bmp"
OnClick="imgPageNext_Command" runat="server" />
<asp:ImageButton ID="ImageButton4" PostBackUrl="~/gridview.aspx" ImageUrl="~/images/ico_suivant.jpg"
OnClick="imgPageLast_Command" runat="server" />
Note that my gridview and the imagebuttons are all inside an updatepanel
and these lines are the lines of my code behind
Protected Sub imgPageFirst_Command(sender As Object, e As ImageClickEventArgs) Handles img_first.Click
GridView1.PageIndex = 0
GridView1.DataBind()
End Sub
Protected Sub imgPagePrevious_Command(sender As Object, e As ImageClickEventArgs) Handles img_previous.Click
Dim i As Integer = GridView1.PageIndex - 1
If GridView1.PageIndex <> 0 Then
GridView1.PageIndex = i
End If
GridView1.DataBind()
End Sub
Protected Sub imgPageNext_Command(sender As Object, e As ImageClickEventArgs) Handles img_next.Click
Dim i As Integer = GridView1.PageIndex + 1
If GridView1.PageIndex < GridView1.PageCount Then
GridView1.PageIndex = i
End If
GridView1.DataBind()
End Sub
Protected Sub imgPageLast_Command(sender As Object, e As ImageClickEventArgs) Handles img_last.Click
GridView1.PageIndex = GridView1.PageCount
GridView1.DataBind()
End Sub