当前位置: 代码迷 >> ASP.NET >> ((GridView)Container.NamingContainer).PageIndex 这是什么意思
  详细解决方案

((GridView)Container.NamingContainer).PageIndex 这是什么意思

热度:7578   发布时间:2013-02-25 00:00:00.0
((GridView)Container.NamingContainer).PageIndex 这是什么意思?

我在GridView中使用自定义分页,参照网上的例子,为什么不成功呀?提示说BC30108:   “GridView”是一个类型,不能用作表达式。请问这如何解决。

<asp:LinkButton   ID= "LinkButtonFirstPage "   runat= "server "   CommandArgument= "First "   CommandName= "Page "
Visible= " <%#   ((GridView)Container.NamingContainer).PageIndex   !=   0   %> "> 首页 </asp:LinkButton>

<asp:LinkButton   ID= "LinkButtonPreviousPage "   runat= "server "   CommandArgument= "Prev "   CommandName= "Page "
Visible= " <%#   ((GridView)Container.NamingContainer).PageIndex   !=   0   %> "> 上一页 </asp:LinkButton>

<asp:LinkButton   ID= "LinkButtonNextPage "   runat= "server "   CommandArgument= "Next "   CommandName= "Page "
Visible= " <%#   ((GridView)Container.NamingContainer).PageIndex   !=   ((GridView)Container.NamingContainer).PageCount   -   1   %> "> 下一页 </asp:LinkButton>

<asp:LinkButton   ID= "LinkButtonLastPage "   runat= "server "   CommandArgument= "Last "   CommandName= "Page "
Visible= " <%#   ((GridView)Container.NamingContainer).PageIndex   !=   ((GridView)Container.NamingContainer).PageCount   -   1   %> "> 尾页 </asp:LinkButton>

------解决方案--------------------------------------------------------
((GridView)Container.NamingContainer).PageIndex 把这个对象转化成GridView的当前的页码
------解决方案--------------------------------------------------------
VB.NET强制类型转换的语法和C#是不一样的
<asp:LinkButton ID= "LinkButtonFirstPage " runat= "server " CommandArgument= "First " CommandName= "Page "
Visible= " <%# (Container.NamingContainer AS GridView).PageIndex != 0 %> "> 首页 </asp:LinkButton>
  相关解决方案