C# 模糊事件参数

C# 模糊事件参数,c#,asp.net,webforms,C#,Asp.net,Webforms,在浏览了SO并阅读了Microsoft SDN归档文件中的EventArgs类之后,我不确定下面的代码是如何获取其数据的 我知道EventArgs只是一个包含数据的参数,但我不知道它是如何包含数据的。下面的方法是通过OnItemDataBound在前面调用的,这很有意义 我已经搜索了隐藏的代码,但是没有ID=“rptSectionDates”的数据绑定,因此我不确定这是如何工作的 问题:有人能告诉我代码隐藏中的e.Item.DataItem有什么数据吗 编辑:展开前部以获取进一步帮助 正面: &

在浏览了SO并阅读了Microsoft SDN归档文件中的EventArgs类之后,我不确定下面的代码是如何获取其数据的

我知道EventArgs只是一个包含数据的参数,但我不知道它是如何包含数据的。下面的方法是通过OnItemDataBound在前面调用的,这很有意义

我已经搜索了隐藏的代码,但是没有
ID=“rptSectionDates”
的数据绑定,因此我不确定这是如何工作的

问题:有人能告诉我代码隐藏中的
e.Item.DataItem
有什么数据吗

编辑:展开前部以获取进一步帮助

正面:

<asp:Repeater ID="rptSections" runat="server" EnableViewState="false" OnItemDataBound="rptSections_ItemDataBound">
<ItemTemplate>
    <div class="section-information-wrapper">
        <div class="section-information-header">
            <div class="section-information-header-left">
                <h3>
                    <span class="section-information-crn-head"><a title="<%# GlobalHelper.GetSetting("Course.CRNToolTip") %>">CRN</a>: </span>
                    <span class="section-information-crn-number"><%# Eval("CRN") %></span>
                </h3>
            </div>
            <div class="section-information-header-right"></div>
        </div>
        <div class="section-information-body">
            <table>
                <thead>
                    <tr class="section-information-subheader">
                        <th class="section-information-date"><h4>Date(s)</h4></th>
                        <asp:PlaceHolder ID="phNonDistanceColumnHeaders" runat="server">
                            <th class="section-information-day"><h4>Day(s)</h4></th>
                            <th class="section-information-time"><h4>Time</h4></th>
                            <th class="section-information-building"><h4>Building</h4></th>
                            <th class="section-information-room"><h4>Room</h4></th>
                        </asp:PlaceHolder>
                    </tr>
                </thead>
                <tbody>
                    <asp:Repeater ID="rptSectionDates" runat="server" OnItemDataBound="rptSectionDates_ItemDataBound">
                        <ItemTemplate>
                            <asp:PlaceHolder ID="phAnd" runat="server" Visible="false">
                                <tr class="section-information-and">
                                    <td colspan="5">
                                        <b>and</b>
                                    </td>
                                </tr>
                            </asp:PlaceHolder>
                            <tr class="section-information-content">
                                <td><asp:Literal ID="litDates" runat="server" /></td>
                                <asp:PlaceHolder ID="phNonDistanceColumns" runat="server">
                                    <td><asp:Literal ID="litDaysOfWeek" runat="server" /></td>
                                    <td><asp:Literal ID="litTimes" runat="server" /></td>
                                    <td><asp:HyperLink ID="hypBuilding" runat="server" Enabled="false" /></td>
                                    <td><asp:HyperLink ID="hypRoom" runat="server" Enabled="false" /></td>
                                </asp:PlaceHolder>
                            </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                </tbody>
            </table>
            <div class="section-information-additional-wrapper clearfix">                                                     
                <div class="section-information-additional-left">
                    <table>
                        <tbody>                  
                            <tr class="section-information-additional">
                                <td class="section-infomation-additional-subheader"><asp:PlaceHolder ID="phTeacher" runat="server" Visible="false"><h4>Teacher: </h4></asp:PlaceHolder></td>
                                <td class="section-infomation-additional-content"><asp:HyperLink ID="hypTeacher" runat="server" Visible="false" /><asp:Literal ID="litTeacher" runat="server" Visible="false" /></td>
                            </tr>
                            <tr class="section-information-additional">
                                <td class="section-infomation-additional-subheader"><h4>Hours: </h4></td>
                                <td class="section-infomation-additional-content"><%=m_Course.CourseHours.ToString("0.##") %></td>
                            </tr>
                            <tr class="section-information-additional">
                                <td class="section-infomation-additional-subheader"><h4>Fee: </h4></td>
                                <td class="section-infomation-additional-content"><asp:Literal ID="litFee" runat="server" /> <asp:Literal ID="litFeeNote" runat="server" /></td>
                            </tr>
                            <tr id="trSectionNotes" runat="server" visible="false" class="section-information-additional">
                                <td class="section-infomation-additional-subheader"><h4>Note: </h4></td>
                                <td class="section-infomation-additional-content"><%# Eval("SectionNotes") %></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div class="section-information-additional-right clearfix">
                    <div class="section-icon-wrapper">
                        <span class="blue-button"><asp:Literal ID="litRegistrationLink" runat="server" /></span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</ItemTemplate>
protected void rptSectionDates_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
        CourseSection section = (CourseSection)e.Item.DataItem;

        if (e.Item.ItemIndex > 0)
        {
            PlaceHolder phAnd = (PlaceHolder)e.Item.FindControl("phAnd");
            phAnd.Visible = true;
        }

        Literal litDates = (Literal)e.Item.FindControl("litDates");

        if (section.StartDate.Date.Equals(section.EndDate.Date))
        {
            litDates.Text = section.StartDate.ToString(DATE_FORMAT);
        }
        else
        {
            litDates.Text = string.Concat(
                section.StartDate.ToString(DATE_FORMAT),
                " &#8211; ", 
                section.EndDate.ToString(DATE_FORMAT));
        }

        ...
}

中继器控件在其代码中填充
EventArgs
,以触发事件。但如何获取数据又有什么关系呢?你具体在寻找什么?或者你是在问数据首先是如何到达中继器的?有些东西正在设置
数据源
的某个地方-在标记或代码隐藏中。我需要检查
部分
变量中存储的数据,因此我将进一步深入到正在更改值的管道中。它们在视图中的显示不正确。如果可以调试应用程序,请在rptSectionDates\u ItemDataBound中的某个位置放置一个断点,然后检查调用堆栈。您应该找到进行数据绑定的位置。如果您不能直接调试,只能修改应用程序,那么您可以使用StackTrace类打印或记录堆栈跟踪信息。啊,您没有告诉我们;-)如果父中继器是数据绑定的,那么父中继器很可能会递归地传递数据绑定。然后将重复调用rptSectionDates_ItemDataBound方法,对父中继器列表中的每个项调用一次,每次调用rptSectionDates_ItemDataBound时,其中一个项将传递给子中继器。