Examples of nested use of data display controls in ASP. Net

Source: Internet
Author: User

Examples of nested use of data display controls in ASP. Net

1. When you encounter such a requirement at work, you need to load all the users on the page, and each User is followed by the task of loading the User! My solution is to use Repeater to load all users and nest a GridView in Repeater to display the tasks of each User! The Code is as follows:

Front-end code:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

<Asp: Repeater ID = "Repeater1" runat = "server"

Onitemdatabound = "repeaterincluitemdatabound">

<HeaderTemplate>

<Table border = "0" cellspacing = "0" cellpadding = "0" width = "100%">

<Tr>

</HeaderTemplate>

<ItemTemplate>

<Td class = "list_table_in">

<Span class = "leaderTitle"> executives: <a href = '/LeaderSchedule/_ layouts/LS/LeaderDetail. aspx? LoginName = <% # Eval ("LoginName") %> '> <% # Eval ("UserName") %> </a> </span> <asp: gridView ID = "gv_InRep" runat = "server" AutoGenerateColumns = "False" AllowSorting = "True"

OnRowCreated = "GV_DoneList_RowCreated" OnSorting = "GV_DoneList_Sorting" AllowPaging = "True"

CssClass = "tasklisttbl" Width = "100%" OnRowDataBound = "GV_DoneList_RowDataBound"

EnableModelValidation = "True">

<AlternatingRowStyle BackColor = "# FDFEFF"/>

<HeaderStyle HorizontalAlign = "Center" ForeColor = "Black" Height = "20"/>

<RowStyle HorizontalAlign = "Center" Height = "26px"/>

<Columns>

<Asp: BoundField HeaderText = "Date" ItemStyle-CssClass = "custom" DataField = "Date" SortExpression = "Date">

& Lt; ItemStyle Width = "15% "/

</Asp: BoundField>

<Asp: BoundField HeaderText = "Time" DataField = "Time" SortExpression = "Time">

& Lt; ItemStyle Width = "11% "/

</Asp: BoundField>

<Asp: BoundField HeaderText = "Work Arrangement" DataField = "WorkPlan" SortExpression = "WorkPlan">

& Lt; ItemStyle Width = "11% "/

</Asp: BoundField>

<Asp: BoundField HeaderText = "location" DataField = "Place" SortExpression = "Place">

<ItemStyle Width = "11%"/>

</Asp: BoundField>

</Columns>

<PagerTemplate>

</PagerTemplate>

</Asp: GridView>

</Td>

<Asp: Literal ID = "Literal1" runat = "server" Text = '<% # Eval ("Flag") %>'> </asp: Literal>

</ItemTemplate>

<FooterTemplate>

</Tr> </table>

</FooterTemplate>

</Asp: Repeater>

Background code:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

Protected void repeaterincluitemdatabound (object sender, RepeaterItemEventArgs e)

{

Try

{

If (e. Item. ItemType = ListItemType. Item | e. Item. ItemType = ListItemType. AlternatingItem)

{

GridView gv = e. Item. FindControl ("gv_InRep") as GridView; // locate the repeater object in the layer

Leader rowv = (Leader) e. Item. DataItem; // locate the data Item associated with the Repeater category

String typeid = rowv. LoginName; // obtain the id of the fill subclass.

SetSorting ();

Gv. DataSource = PointDataSource (typeid );

Gv. DataBind ();

}

}

Catch (Exception ex)

{

SysLog syslog = new SysLog ();

Syslog. ListName = ConstData. ListName_PCITC_LS_Schedule;

Syslog. LType = "the Item binding event of Repeater is abnormal ";

Syslog. WorkFlowName = "lead the calendar management system ";

Syslog. Location = "Repeater Binding data: OtherSchedule. aspx ";

Syslog. Message = "Page Information loading exception:" + ex. Message;

Syslog. DataSource = 0;

Logprovider. AddAuditRecordToSource (syslog );

}

}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.