•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 391,588 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,656 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 591 | Replies: 0
![]() |
•
•
Join Date: Jun 2008
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
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:
and vb code:
End Sub
Thank you
ASP.NET Syntax (Toggle Plain Text)
<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:
VB Syntax (Toggle Plain Text)
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
Last edited by peter_budo : Jun 20th, 2008 at 8:55 am. Reason: Keep It Organized - please use [code] tags
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
Similar Threads
- Dreamweaver problem... (ASP.NET)
- Help with ASP code (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: Expanding my knowledge
- Next Thread: Providing Popup reminders for events


Linear Mode