Hi there,
Yes, you're correct. This is indeed a problem.
Quote:
|
I presume that there's a nice easy fix for this... some C# code for the dropdown On Select method to initialise the ListView, perhaps
|
And that's indeed the fix. For a detailed explanation, check out this post:
http://leedumond.com/blog/resetting-...in-a-listview/
The following should do the trick:
Code:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
CommandEventArgs commandEventArgs = new CommandEventArgs("First", "");
DataPager pager = ListView1.FindControl("DataPager1") as DataPager;
if (pager != null)
{
NextPreviousPagerField nextPreviousPagerField = pager.Fields[0] as NextPreviousPagerField;
if (nextPreviousPagerField != null)
{
nextPreviousPagerField.HandleEvent(commandEventArgs);
}
}
}
This also requires the following addition to the DropDownList in markup:
Code:
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="EntityDataSource1" DataTextField="Name" DataValueField="Id" onselectedindexchanged="DropDownList1_SelectedIndexChanged" />
For future posts like these, you're better off posting in the book's own forum category:
http://p2p.wrox.com/book-beginning-asp-net-4-c-vb-560/
Hope this helps,
Imar