开发者

Is using ObjectDataSource a good practice?

In my company few of the employees are using ObjectDataSource. Example snippet is :

<asp:ObjectDataSource ID="odsRequirement" runat="server" EnablePaging="True" 
                      MaximumRowsParameterName="intMaxRows"
                      SelectMethod="GetAll" 
                      StartRowIndexParameterName="intRowIndex" 
                      TypeName="MyNamespace.MyType" 
                      SortParameterName="SortString"
                      OnSelecting="odsRequirement_Selecting"
                      SelectCountMethod="GetAllCount">
    <SelectParameters>
        <asp:Parameter Name="A" DefaultValue="null" />
        <asp:Parameter Name="B" DefaultValue="null" />
        <asp:Parameter Name="C" />
        <asp:Parameter Name="D" />
        <asp:Parameter Name="E" />
    </SelectParameters>
</asp:ObjectDataSource>

Will the SelectC开发者_如何转开发ountMethod GetAllCount be always fired after the SelectMethod GetAll? And is there a better way we should be doing this?

Thanks in advance:)


Personally I'm not a big fan of these types of controls. I much prefer getting data from the code-behind and binding the data to the page. My problem is that you're baking domain logic into the ASPX page itself. I'd recommend seperating that by moving the code which gets the data into another class, which should be in another layer (i.e. Domain, or Model - which are usually class libraries).

Regardless, try to get away from using this control and move the data gathering logic into another file. In the long term, you will see the benefits.

http://geekswithblogs.net/opiesblog/archive/2006/09/11/90906.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜