Ok, so I've got a page with a listview and three datapagers. However, the issue I'm having is with just one of the datapagers, I mention the others just in case they can interfere somehow (new to this listview/datapager business).
This is the datapager giving me trouble:
<asp:DataPager Visible="false" ID="alphabetPager1" PagedControlID="ListView1" runat="server" PageSize="15">
<Fields>
<asp:TemplatePagerField OnPagerCommand="TemplatePagerField_OnPagerCommand">
<PagerTemplate>
<asp:LinkButton runat="server" CommandName="#" ID="pound">#</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="A" ID="a">A</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="B" ID="b">B</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="C" ID="c">C</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="D" ID="d">D</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="E" ID="e">E</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="F" ID="f">F</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="G" ID="g">G</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="H" ID="h">H</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="I" ID="i">I</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="J" ID="j">J</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="K" ID="k">K</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="L" ID="l">L</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="M" ID="m">M</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="N" ID="n">N</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="O" ID="o">O</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="P" ID="p">P</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="Q" ID="q">Q</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="R" ID="r">R</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="S" ID="s">S</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="T" ID="t">T</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="U" ID="u">U</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="V" ID="v">V</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="W" ID="w">W</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="X" ID="x">X</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="Y" ID="y">Y</asp:LinkButton>
<asp:LinkButton runat="server" CommandName="Z" ID="z">Z</asp:LinkButton>
</PagerTemplate>
</asp:TemplatePagerField>
</Fields>
</asp:DataPager>
Essentially all TemplatePagerField_OnPagerCommand does is change the value of a Control parameter on an ObjectDataSource that is feeding the list view. So click on one of the letters and the listview is bound to the items that begin with that letter. This works just fine, as long as there are some results. However, as soon as I click a letter for which there are no objects in the database it seems to me that TemplatePagerField_OnPagerCommand is no longer called. alphabetPager1 still exists on the page, I can see it and click on its items but nothing happens. If I click on something else that resets the value of the Control Parameter TemplatePagerField_OnPagerCommand should be controlling then everything works again. What gives? If clarification or more of the code is needed, just ask. Thanks in advance.
This is TemplatePagerField_OnPagerCommand and the relevant function it calls.
protected void TemplatePagerField_OnPagerCommand(object sender, DataPagerCommandEventArgs e)
{
Response.Write("We're about to switch!");
switch (e.CommandName)
{
case "forward": forward_Click(); break;
case "#": alpha_Click("#"); break;
case "A": alpha_Click("A"); break;
case "B": alpha_Click("B"); break;
case "C": alpha_Click("C"); break;
case "D": alpha_Click("D"); break;
case "E": alpha_Click("E"); break;
case "F": alpha_Click("F"); break;
case "G": alpha_Click("G"); break;
case "H": alpha_Click("H"); break;
case "I": alpha_Click("I"); break;
case "J": alpha_Click("J"); break;
case "K": alpha_Click("K"); break;
case "L": alpha_Click("L"); break;
case "M": alpha_Click("M"); break;
case "N": alpha_Click("N"); break;
case "O": alpha_Click("O"); break;
case "P": alpha_Click("P"); break;
case "Q": alpha_Click("Q"); break;
case "R": alpha_Click("R"); break;
case "S": alpha_Click("S"); break;
case "T": alpha_Click("T"); break;
case "U": alpha_Click("U"); break;
case "V": alpha_Click("V"); break;
case "W": alpha_Click("W"); break;
case "X": alpha_Click("X"); break;
case "Y": alpha_Click("Y"); break;
case "Z": alpha_Click("Z"); break;
default: back_Click(); break;
}
}
protected void alpha_Click(string letter)
{
hidAlpha.Value = letter;
Response.Write("The value of hidden alpha is: " + hidAlpha.Value);
}
The prints are just in there for debug :). The control parameter takes on the value of hidAlpha.