saquib189 0 Newbie Poster

Hi all i have a datalist and i enable paging in it. but the link button not work when i click on it. The code is shown below:

<asp:Panel ID="Panel2" runat="server">

<font size="-1" face="Verdana, Arial, Helvetica, sans-serif"><asp:label id="pageNumber" runat="server" /></font>

<asp:DataList ID="theDataList" runat="server" RepeatColumns="4" Width="616px" CellPadding="4" ForeColor="#333333">

<HeaderTemplate>

Book Listing

</HeaderTemplate>

 

<ItemTemplate>

<asp:Image ID="Image1" Width="100" Height="100" Runat="Server"

AlternateText='<%# "Picture of " & Eval("image") %>'

ImageUrl='<%# "images/" & Eval("image") & ".jpg" %>' /> 
<br /><br />

<asp:HyperLink ID="HyperLink2" Runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"BookTitle") %>' NavigateUrl='<%# "Details.aspx?BookID=" & Container.DataItem("BookID") %>' />

</ItemTemplate>

<ItemStyle HorizontalAlign="Center" BackColor="#EFF3FB" />

<SeparatorStyle BackColor="Maroon" BorderStyle="Dotted" />

<HeaderStyle BackColor="#507CD1" Font-Bold="True" Font-Size="12pt" ForeColor="White"

HorizontalAlign="Center" />

<FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True" />

<SelectedItemStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />

<AlternatingItemStyle BackColor="White" />

 

 

</asp:DataList>

<asp:LinkButton id="btnPrev" Text="Prev" OnClick="Prev_Click" runat="server" />

 

<asp:LinkButton id="btnNext" Text="Next" OnClick="Next_Click" runat="server" /> 
</asp:Panel>

and vb code:

Private pagedData As New PagedDataSource() 
 

 

Public Function getTheData() As DataTable 
 

Dim DS As New DataSet()Dim myConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("SecurityTutorialsConnectionString").ConnectionString) 
 

Dim objSQLAdapter As New SqlDataAdapter("SELECT * FROM BooksDB", myConnection)

objSQLAdapter.Fill(DS, "BooksDB") 
 

 

Return DS.Tables(0) 
 

End Function

Private Sub doPaging() 
 

pagedData.DataSource = getTheData().DefaultView

 

pagedData.AllowPaging = True

pagedData.PageSize = 20

 

 

 

Try

pagedData.CurrentPageIndex = Int32.Parse(Request("Page").ToString())Catch ex As Exception 
 

 

 

 

 

 

pagedData.CurrentPageIndex = 0

End Try

 

btnPrev.Visible = (Not pagedData.IsFirstPage) 
 

btnNext.Visible = (Not pagedData.IsLastPage) 
 

 

 

theDataList.DataSource = pagedData

 

theDataList.DataBind()

 

End Sub

Private Sub Prev_Click(ByVal obj As Object, ByVal e As EventArgs) 
 

Response.Redirect(Request.CurrentExecutionFilePath + "?Page=" + (pagedData.CurrentPageIndex - 1)) 
End Sub

Private Sub Next_Click(ByVal obj As Object, ByVal e As EventArgs) 
 

Response.Redirect(Request.CurrentExecutionFilePath + "?Page=" + (pagedData.CurrentPageIndex + 1)) 
End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

doPaging()

End Sub

Thank you