Winson.Thoughts.ToString()

Happy Programming, Happy Life

  博客园 :: 首页 :: 博问 :: 闪存 :: :: :: :: 管理 ::

In my current project, we are using CodeSmith + netTiers as framework. It is a great framework for rapid development.

Today I will explain how to use DeepLoad features in netTiers.

We have two tables, one is PortalReports, it contains a foreign key call ReportTypeId to the other table call PortalReportTypes.  In PortalReportTypes we have a column call ReportTypeName. What we want is in GridView, we need to show ReportTypeName rather than  ReportTypeId. I think it is a very common requirement. So how can be done using the DeepLoad features in netTiers framework and not write any code?  

<asp:GridView ID="gvReport" HeaderStyle-CssClass="gridheader" AllowSorting="true" DataKeyNames="ReportId" DataSourceID="dsReport" OnRowCommand="gvReport_RowCommand"
AllowPaging
="true" runat="server" AutoGenerateColumns="false" Width="500px">
  
<Columns>
    
<asp:TemplateField>
      
<HeaderTemplate>Report Type</HeaderTemplate>
      
<ItemTemplate><%#Eval("ReportTypeIdSource.ReportName")%></ItemTemplate>
    
</asp:TemplateField>
  
</Columns>
</asp:GridView>
<data:PortalReportsDataSource ID="dsReport" runat="server" EnablePaging="True" EnableSorting="True" EnableTransaction="False" SelectMethod="GetPaged" EnableDeepLoad="true">
    
<DeepLoadProperties Method="IncludeChildren" Recursive="false">
        
<Types>
            
<data:PortalReportsProperty Name="PortalReportTypes" />
        
</Types>
    
</DeepLoadProperties>
</data:PortalReportsDataSource>

The import things here are
1. EnableDeepLoad="true"
2. <%#Eval("ReportTypeIdSource.ReportName")%> should be foreignkey+"Source".PropertyName

posted on 2008-11-28 14:49  winsonweb  阅读(562)  评论(0编辑  收藏  举报