首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >列表视图中的DataPager查找控件

列表视图中的DataPager查找控件
EN

Stack Overflow用户
提问于 2013-12-19 01:33:10
回答 1查看 947关注 0票数 0

更新:

我正在尝试使用这段代码访问DataPager,但是我似乎没有正确的语法。

代码语言:javascript
复制
Dim myDP As DataPager = TryCast(ListView1.LayoutTemplate("DataPager1", DataPager).FindControl("DataPager1"), DataPager)

我在ListView中有一个DataPager,想要读取DataPager中textbox的值……

代码语言:javascript
复制
<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;">
                &nbsp;</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值...

代码语言:javascript
复制
 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
EN

回答 1

Stack Overflow用户

发布于 2014-01-10 18:15:55

代码语言:javascript
复制
pager.Controls[0].FindControl("slider1") as TextBox
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20664697

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档