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

  • 2021-01-11 01:57:49
  • OfStack

1. There is a need to load all User on the page, and each User must be followed by the User task! My solution is to use Repeater to load all User's, and to nest one GridView inside Repeater to show the task of each User! The following code

Front Desk Code:

<asp:Repeater ID="Repeater1" runat="server" 
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<td class="list_table_in">

<span class="leaderTitle"> Executive: <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"
<AlternatingRowStyle BackColor="#FDFEFF" />
<HeaderStyle HorizontalAlign="Center" ForeColor="Black" Height="20" />
<RowStyle HorizontalAlign="Center" Height="26px" />
<asp:BoundField HeaderText=" The date of " ItemStyle-CssClass="custom" DataField="Date" SortExpression="Date">
<ItemStyle Width="15%" />
<asp:BoundField HeaderText=" time " DataField="Time" SortExpression="Time">
<ItemStyle Width="11%" />
<asp:BoundField HeaderText=" Work arrangement " DataField="WorkPlan" SortExpression="WorkPlan">
<ItemStyle Width="11%" />
<asp:BoundField HeaderText=" place " DataField="Place" SortExpression="Place">
<ItemStyle Width="11%" />
<asp:Literal ID="Literal1" runat="server" Text='<%#Eval("Flag") %>'></asp:Literal>

Background code:

protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
GridView gv = e.Item.FindControl("gv_InRep") as GridView;// Find the inner layer repeater object 
Leader rowv = (Leader)e.Item.DataItem;// Find a classification Repeater The associated data item  
string typeid = rowv.LoginName; // Gets the populated subclass id 
gv.DataSource = PointDataSource(typeid);


catch (Exception ex)

SysLog syslog = new SysLog();
syslog.ListName = ConstData.ListName_PCITC_LS_Schedule;
syslog.LType = "Repeater the Item Binding event exception ";
syslog.WorkFlowName = " Lead the schedule management system ";
syslog.Location = "Repeater Binding data: OtherSchedule.aspx";
syslog.Message = " Error loading of page information: " + ex.Message;
syslog.DataSource = 0;

Related articles: