所以加了判断,如果没有DeepLoad则会抛出异常
1
public
partial
class
Contract : ContractBase
2 {
3 #region Constructors
4
5 /// <summary>
6 /// Creates a new <see cref="Contract"/> instance.
7 /// </summary>
8 public Contract() : base () { }
9
10
11 #endregion
12
13 /// <summary>
14 /// 合同签约人 - -b 名字比较烂
15 /// </summary>
16 public string ContractPersonName
17 {
18 get
19 {
20 if ( this .FContractPerson != null && this .FContractPersonSource == null )
21 throw new Exception( " 没有使用Deepload " );
22
23 if ( this .FContractPerson == null )
24 return String.Empty;
25
26 return this .FContractPersonSource.FName;
27 }
28 }
29
30 }
2 {
3 #region Constructors
4
5 /// <summary>
6 /// Creates a new <see cref="Contract"/> instance.
7 /// </summary>
8 public Contract() : base () { }
9
10
11 #endregion
12
13 /// <summary>
14 /// 合同签约人 - -b 名字比较烂
15 /// </summary>
16 public string ContractPersonName
17 {
18 get
19 {
20 if ( this .FContractPerson != null && this .FContractPersonSource == null )
21 throw new Exception( " 没有使用Deepload " );
22
23 if ( this .FContractPerson == null )
24 return String.Empty;
25
26 return this .FContractPersonSource.FName;
27 }
28 }
29
30 }
建一个实体数据源和一个GridView,允许DeepLoad但不允许递归,不允许事务,允许分页和排序,使用GetPaged方法进行查询
DeepLoad Users对象,再添加5个参数,4个输入,1个输出,PageIndex,OrderBy和PageSize都取GridView的属性
最后再添加一个过滤的参数...
1
<
asp:DropDownList
ID
="NameList"
AutoPostBack
="true"
runat
="server"
>
2 < asp:ListItem Value ="" > All </ asp:ListItem >
3 < asp:ListItem > iCaca </ asp:ListItem >
4 < asp:ListItem > Sun </ asp:ListItem >
5 < asp:ListItem > Grubby </ asp:ListItem >
6 < asp:ListItem > Sky </ asp:ListItem >
7 < asp:ListItem > Moon </ asp:ListItem >
8 </ asp:DropDownList >
9 < data:ContractDataSource ID ="source" runat ="server" EnablePaging ="True" EnableSorting ="True"
10 EnableTransaction ="False" SelectMethod ="GetPaged" EnableDeepLoad ="True" >
11 < DeepLoadProperties Method ="IncludeChildren" Recursive ="False" >
12 < Types >
13 < data:ContractProperty Name ="Users" />
14 </ Types >
15 </ DeepLoadProperties >
16 < Parameters >
17 < data:SqlParameter Name ="WhereClause" UseParameterizedFilters ="false" >
18 < Filters >
19 < data:ContractFilter Column ="FContractPerson" ControlID ="NameList" />
20 </ Filters >
21 </ data:SqlParameter >
22 < asp:ControlParameter Name ="OrderBy" ControlID ="GridView1" PropertyName ="SortExpression"
23 Type ="String" />
24 < asp:ControlParameter Name ="PageIndex" ControlID ="GridView1" PropertyName ="PageIndex"
25 Type ="Int32" />
26 < asp:ControlParameter Name ="PageSize" ControlID ="GridView1" PropertyName ="PageSize"
27 Type ="Int32" />
28 < asp:Parameter Name ="RecordCount" Type ="Int32" />
29 </ Parameters >
30 </ data:ContractDataSource >
31 < asp:GridView ID ="GridView1" runat ="server" AllowPaging ="True" DataKeyNames ="FId"
32 DataSourceID ="source" AllowSorting ="True" >
33 < Columns >
34 < asp:BoundField DataField ="ContractPersonName" />
35 </ Columns >
36 </ asp:GridView >
37
2 < asp:ListItem Value ="" > All </ asp:ListItem >
3 < asp:ListItem > iCaca </ asp:ListItem >
4 < asp:ListItem > Sun </ asp:ListItem >
5 < asp:ListItem > Grubby </ asp:ListItem >
6 < asp:ListItem > Sky </ asp:ListItem >
7 < asp:ListItem > Moon </ asp:ListItem >
8 </ asp:DropDownList >
9 < data:ContractDataSource ID ="source" runat ="server" EnablePaging ="True" EnableSorting ="True"
10 EnableTransaction ="False" SelectMethod ="GetPaged" EnableDeepLoad ="True" >
11 < DeepLoadProperties Method ="IncludeChildren" Recursive ="False" >
12 < Types >
13 < data:ContractProperty Name ="Users" />
14 </ Types >
15 </ DeepLoadProperties >
16 < Parameters >
17 < data:SqlParameter Name ="WhereClause" UseParameterizedFilters ="false" >
18 < Filters >
19 < data:ContractFilter Column ="FContractPerson" ControlID ="NameList" />
20 </ Filters >
21 </ data:SqlParameter >
22 < asp:ControlParameter Name ="OrderBy" ControlID ="GridView1" PropertyName ="SortExpression"
23 Type ="String" />
24 < asp:ControlParameter Name ="PageIndex" ControlID ="GridView1" PropertyName ="PageIndex"
25 Type ="Int32" />
26 < asp:ControlParameter Name ="PageSize" ControlID ="GridView1" PropertyName ="PageSize"
27 Type ="Int32" />
28 < asp:Parameter Name ="RecordCount" Type ="Int32" />
29 </ Parameters >
30 </ data:ContractDataSource >
31 < asp:GridView ID ="GridView1" runat ="server" AllowPaging ="True" DataKeyNames ="FId"
32 DataSourceID ="source" AllowSorting ="True" >
33 < Columns >
34 < asp:BoundField DataField ="ContractPersonName" />
35 </ Columns >
36 </ asp:GridView >
37
到底是网页绑定好还是后台绑定好,也要看具体的情况而定~
如果太复杂...还是后台吧...