asp.net listview + asp.net datapager on JQuery Mobile ?
Greetings... and thank you for using your time reading my post..
I'm developing in asp.net (c#) using latest stable JQuery Mobile version.
I have a need for a datapager on a listview, and naturally enough.. i'm using the asp.net version one "Datapager", but... since the datapager does a postback each time.. it causes issues with JQuery Mobile.
I guess... i need a easier more compatible way of using a pager to this.. Any ideas ?
here is the code :
<table>
<tr>
<td style="vertical-align:top">
<asp:DataPager ID="dpWeeksPrev" runat="server" PagedControlID="lvWeeks" PageSize="5">
<Fields>
<asp:NextPreviousPagerField ShowNextPageButton="False" ButtonCssClass="previousPagerLink" />
</Fields>
</asp:DataPager>
</td>
<td>
<ul data-role="fieldcontain" class="nolefuquewiththepreviouselement">
<asp:ListView ID="lvWeeks" runat="server">
<ItemTemplate>
<div style="float: left">
<a class="weeknumber" style="padding: 0px;" data-role="button">
<%# Eval("WeekNumber") %></a>
</div>
</ItemTemplate>
</asp:ListView>
</ul>
</td>
<td style="vertical-align: top">
<asp:DataPager ID="dpWeeksNext" runat="server" PagedControlID="lvWeeks" PageSize="5">
<Fields>
<asp:NextPreviousPagerField ShowPreviousPageButton="False" ButtonCssClass="nextPagerLink" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
BACK_END
private void populateWeekNumbersControl(DateTime? selDate)
{
//nextPage.NextPageImageUrl = Assets.Image.GetUrl("arrow_right.png").ToString();
//prevPage.PreviousPageImageUrl = Assets.Image.GetUrl("arrow_left.png").ToString();
const int maxWeeks = 53;
int counterWeek = 1;
List<WeekNumbers> weeks = new List<WeekNumbers>();
while (counterWeek <= maxWeeks)
{
WeekNumbers week = new WeekNumbers {WeekNumber = counterWeek};
weeks.Add(week);
counterWeek++;
}
lvWeeks.DataSource = weeks;
lvWeeks.DataBind();
int currWeek = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(Convert.ToDateTime(selDate), CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
double totPageIndexes = Math.Ceiling((double)maxWeeks/5);
double currPageIndex = Math.Ceiling((double)currWeek/5);
dpWeeksNext.SetPageProperties(Convert.ToInt32(currPageIndex-1), 5, true);
dpWeeksPrev.SetPageProperties(Convert.ToInt32(currPageIndex-1), 5, true);
summary.Text = "TotalIndexes = " + totPageIndexes + ", CurrentIndex = " + currPageIndex;
}