zoukankan      html  css  js  c++  java
  • siteFactory中的GridView跟ObjectDataSource 在

       在动易SiteFactory RC版的后台内管理页面中,你可以看到很多列表页都是采用GridView加ObjectDataSource实现的,
    当然动易后台并不是直接使用GridView,而是对其进行了扩展ExtendedGridView(在PowerEasy.Controls.dll),主要定义了分页显示功能.
      ObjectDataSource是Asp.net 2.0中新出现的数据源控件,它的目的是实现gridview与业务逻辑层的沟通,相比sqlDataSource,objectDataSource是专门为N层的系统设计而提供的组件.
       在动易系统的/Admin/Contents/ContentManage.aspx中有如下代码片段
       GridView 部分
        <pe:ExtendedGridView ID="EgvContent" runat="server" DataSourceID="OdsContents" SerialText=""
            AutoGenerateCheckBoxColumn="True" AutoGenerateColumns="False" AllowPaging="True"
            OnRowDataBound="EgvContent_RowDataBound" OnRowCommand="EgvContent_RowCommand"
            DataKeyNames="GeneralId" CheckBoxFieldHeaderWidth="3%">

       ObjectDataSource 部分
           <asp:ObjectDataSource ID="OdsContents" runat="server" SelectMethod="GetSearchContentList"
            TypeName="PowerEasy.Contents.ContentManage" EnablePaging="True" MaximumRowsParameterName="maxNumberRows"
            StartRowIndexParameterName="startRowIndexId" SelectCountMethod="GetTotalOfCommonModelInfo
    ">
            <SelectParameters>
                <asp:QueryStringParameter Name="nodeId" QueryStringField="NodeID" Type="Int32" />
                <asp:ControlParameter ControlID="HdnListType" Type="Int32" Name="sortType" PropertyName="Value" />
                <asp:ControlParameter ControlID="HdnStatus" Type="Int32" Name="status" PropertyName="Value" />
                <asp:ControlParameter ControlID="HdnSearchType" Type="String" Name="searchType" PropertyName="Value" />
                <asp:ControlParameter ControlID="HdnSearchKeyword" Type="String" Name="keyword" PropertyName="Value" />
            </SelectParameters>
        </asp:ObjectDataSource>

      SiteFactory中内容管理的业务逻辑封装在PowerEasy.Contents.ContentManage中,方法
    public static IList GetSearchContentList(int startRowIndexId, int maxNumberRows, int nodeId, ContentSortType sortType, int status, string searchType, string keyword) 最调掉用存储过程PR_Common_GetListBySortColumn--关于这个存储过程可以参考 基于 Set Rowcount的分页存储过程
        留意ObjectDataSource里的属性我们可以看到,在里面我们指定了GetSearchContentList方法的调用参数名,
    startRowIndexId,maxNumberRows(页面大小),至于nodeId,status....等我们配置在<SelectParameters>...</..>里,当你需要起用分页时,务必设置ObjectDataSource中的EnablePaging="True" ,不然MaximumRowsParameterName等属性将无效GridView也不会把PageIndex属性传递个ObjectDataSource,
       当页面运行时,GridView会把当前页码,页面大小,排序表达式(在objectDataSource中指定了SortParameterName="xxx")传递给ObjectDataSource,接着ObjectDataSource回把这些值进行换算,来调用SelectMethod中指定的方法以反回数据,其中排序表达式传递到方法内的通常是 "AddTime | AddTime DESC" 这样的形式.

      在启用了GridviewEx(sitefactory中的控件)的选择列后(checkbox)需要注意的,gridViewEx会有个Bug就是在匹配对应的操作函数(update,insert)时会有一个没名称的参数,如 Id,,hits 注意中间的",," 昨天没发现,以至调试了半天,
    解决办法是不用ODS的帮定Update方法,而使用GridViewEx 的RowUpdateing事件,或使用ODS的Updateing也可以,只要完成更新后将调用链截断就好,如使用GridViewEx的RowUpdateing时,设置e.Cancel=True等

  • 相关阅读:
    class11_创建新的输出字段P2
    class10_创建新的输出字段
    class09_高级过滤数据
    Markdown高级语法
    class08_过滤数据
    class07_查询数据
    class06_插入数据
    class05_操纵表
    class04_创建表02
    class03_Create a new table by SQL
  • 原文地址:https://www.cnblogs.com/wdfrog/p/1069505.html
Copyright © 2011-2022 走看看