更新:
我正在尝试使用此代码访问DataPager,但我似乎没有正确的语法。
Dim myDP As DataPager = TryCast(ListView1.LayoutTemplate("DataPager1", DataPager).FindControl("DataPager1"), DataPager)
我在ListView中有一个DataPager,想要读取DataPager中文本框的值......
<asp:DataPager ID="DataPager1" runat="server" PagedControlID="ListView1" PageSize="1">
<Fields>
<asp:TemplatePagerField OnPagerCommand="TemplatePagerField_OnPagerCommand" >
<PagerTemplate>
<div>
<asp:LinkButton ID="FirstButton" runat="server" CommandName="First"
Text="<<" Enabled='<%# Container.StartRowIndex > 0 %>' />
<asp:LinkButton ID="PreviousButton" runat="server" CommandName="Previous"
Text='<%# (Container.StartRowIndex - Container.PageSize + 1) & " - " & (Container.StartRowIndex) %>' Visible='<%# Container.StartRowIndex > 0 %>' />
<asp:Label ID="CurrentPageLabel" runat="server"
Text='<%# (Container.StartRowIndex + 1) & "-" & (IIf(Container.StartRowIndex + Container.PageSize > Container.TotalRowCount, Container.TotalRowCount, Container.StartRowIndex + Container.PageSize)) %>' />
<asp:LinkButton ID="NextButton" runat="server" CommandName="Next"
Text='<%# (Container.StartRowIndex + Container.PageSize + 1) & " - " & (IIf(Container.StartRowIndex + Container.PageSize*2 > Container.TotalRowCount, Container.TotalRowCount, Container.StartRowIndex + Container.PageSize*2)) %>' Visible='<%# (Container.StartRowIndex + Container.PageSize) < Container.TotalRowCount %>' />
<asp:LinkButton ID="LastButton" runat="server" CommandName="Last" Text=">>" Enabled='<%# Container.TotalRowCount %>' />
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" style="width: 25px;">
</td>
<td align="center" style="width: 200px;">
<asp:TextBox ID="txtSlider" runat="server" AutoPostBack="True" Text='<%# (Container.StartRowIndex + 1) %>' OnTextChanged="txtSlider_TextChanged" Width="200px"></asp:TextBox>
<asp:SliderExtender ID="SliderExtender1" runat="server" Orientation="Horizontal"
TargetControlID="txtSlider"></asp:SliderExtender>
</td>
<td align="right" style="padding-right: 25px" class="PageNumber">
<asp:Label ID="lblPaging" runat="server" Text='<%# "Page " & (Container.StartRowIndex + 1) & " of " & (Container.TotalRowCount) %>'></asp:Label>
</td>
</tr>
</table>
</div>
</PagerTemplate>
更新:
我正在尝试读取DataPager中的TB值...
Protected Sub txtSlider_TextChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim lv As ListView = TryCast(sender, ListView)
Dim pager As DataPager = TryCast(lv.FindControl("DataPage1"), DataPager)
Dim tb As TextBox = TryCast(pager .FindControl("slider1"), TextBox)
Dim CurrentPage As Integer = tb.Text
答案 0 :(得分:1)
pager.Controls[0].FindControl("slider1") as TextBox