Showing posts with label paging. Show all posts
Showing posts with label paging. Show all posts

Monday, March 26, 2012

Dynamic Accordion with Paging

hi there; using asp.net 2.0 (vb) i've just created a page that, in the page load event, retreives a number of records from the database.

as each record is read into a dataset, a new accordon panel is created. the panel header displays the fldName and the panel content displays the fldContent from the table.

this all works great. the issue i'm having is that it currently displays all the records (approx 200) and i only want 10 records displayed at a time.

my question is, is there somehow a way to implement paging? i found the following article:

http://rolf-cerff.de/blogs/dotnet/archive/2007/03/08/ajax-control-toolkit-paging-with-databound-accordion-control.aspx

but i'm not familiar enough with C# to understand.

also, any idea if paging for the accordion is in the works?

thanks all.

You can use a paged data source...

Basically, create a datatable from your recordset, and then...
Dim pds As New PagedDataSource
pds.DataSource = (whatever then dataset is called).Tables(0).DefaultView
pds.AllowPaging = True
pds.PageSize = 10
pds.CurrentPageIndex = curpage (passed into the databind sub, optional value that = 0 at first)
CurrentPage (see below) = pds.CurrentPageIndex + 1

What I do is to create a viewstate item called CurrentPage to keep track of the pages...
Public Property CurrentPage() As Integer
Get
Dim o As Object = Me.ViewState.Item("_CurrentPage")
If o Is Nothing Then
Return 0
Else
Return o
End If
End Get
Set(ByVal value As Integer)
Me.ViewState.Item("_CurrentPage") = value
End Set
End Property

You can then have linkbuttons to guide through pages... Just rebind using your sub and pass in CurrentPage as the curpage to advance or CurrentPage - 1 to go back.

Wednesday, March 21, 2012

DropDownList and Ajax

Hello Everyone,

having very weird bug ,

page consists of following controls
- DataList to show records
- object data source
- PagedDataSource for paging of datalist (code behind)
- DropDownList for selecting paging size with values 3, 5(default), 10, 15

All above controls are kept in UpdatePanel.

Working of page

On DropDownList1_SelectedIndexChanged event I am setting PagedDataSource1.PageSize to DropDownList1.SelectedValue, then bind the DataList Control to show the records.

This works fine for the first run of the page, I get 5 records per page. If I change paging size to some other values it works, but when I change it to same default value i.e. 5 the DropDownList1.SelectedValue returns blank. Similar thing happens for any value which is set to default in DropDownList.

Thanks in Advance

Nitin Pawar

Hi Niyin,

To troubleshoot this issue, we really need the source code to reproduce the problem, so that we can investigate the issue in house. It is not necessary that you send out the complete source of your project. We just need a simplest sample to reproduce the problem. You can remove any confidential information or business logic from it.