I use a repeater control inside in upadte panel to bring some data from my db.
<asp:updatepanel id="UpdatePanel1" runat="server" updatemode="Conditional" xmlns:asp="#unknown">
<contenttemplate>
<asp:hyperlink id="linkPrev" runat="server"><< </asp:hyperlink>
<asp:hyperlink id="linkNext" runat="server"> >></asp:hyperlink>
<asp:repeater id="Repeater1" runat="server">
<itemtemplate>
<%#DataBinder.Eval(Container.DataItem, "date")%><br />
Title:<br />
<%#DataBinder.Eval(Container.DataItem, "title")%>
<asp:hyperlink id="lnkDetails" runat="server" navigateurl="<%# Eval("item_ID", "~/Details.aspx?ID={0}") %>">more</asp:hyperlink>
<br />
<br />
<hr width="100px" />
<br />
</itemtemplate>
</asp:repeater>
</contenttemplate>
</asp:updatepanel>
In my code behind I have
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim strsql As String = "SELECT * FROM news ORDER BY news.item_ID DESC"
Dim sqlconn As New SqlConnection
sqlconn.ConnectionString = ConfigurationManager.ConnectionStrings("mycon").ToString
sqlconn.Open()
Dim cmd As New SqlCommand(strsql, sqlconn)
Dim da As New SqlDataAdapter(strsql, sqlconn)
Dim table As New DataTable()
da.Fill(table)
Dim pds As New PagedDataSource()
pds.DataSource = table.DefaultView
pds.AllowPaging = True
pds.PageSize = 5
Dim currentPage As Integer
If Request.QueryString("page") IsNot Nothing Then
currentPage = Int32.Parse(Request.QueryString("page"))
Else
currentPage = 1
End If
pds.CurrentPageIndex = currentPage - 1
If Not pds.IsFirstPage Then
linkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" & (currentPage - 1)
End If
If Not pds.IsLastPage Then
linkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" & (currentPage + 1)
End If
Repeater1.DataSource = pds
Repeater1.DataBind()
cmd.Connection.Close()
cmd.Connection.Dispose()
End If
End Sub
The paging works fine, but it reloads the hole page.
I dont want to use a gridview because I need to display my data in a certain way.
Do I have to use triggers and link buttons? Do you know how I have to transform my code?
thank you