protected void Page_Load(object sender, EventArgs e)
    {
        #region 校验页面参数

        bool bIsValid = PageCommon.ValidateQueryString(this, "ContactID", QueryStringType.ID);
        if (bIsValid == false)
        {
            try
            {
                this.Response.End();
            }
            catch
            {
            }
        }

        this.iContactID = Convert.ToInt32(this.Request.QueryString["ContactID"]);

        #endregion

        #region 加载Relationship数据

        #region get row count

        Contacts ContactManager = new Contacts();
        int      iRowCount      = ContactManager.GetRelatedContactCount(this.iContactID);
        this.AspNetPager1.RecordCount = iRowCount;

        #endregion

        #region Calc. StartIndex and EndIndex

        int iPageSize  = this.AspNetPager1.PageSize;
        int iPageIndex = 1;
        if (this.Request.QueryString["PageIndex"] != null)
        {
            iPageIndex = Convert.ToInt32(this.Request.QueryString["PageIndex"]);
        }
        int iStartIndex = PageCommon.CalcStartIndex(iPageIndex, iPageSize);
        int iEndIndex   = PageCommon.CalcEndIndex(iStartIndex, iPageSize, iRowCount);

        #endregion

        #region 获取Related Contact List

        RelationshipManager   RelationshipManager1 = new RelationshipManager();
        List <RelatedContact> RelationshipList     = RelationshipManager1.GetRelatedContacts(this.iContactID, iStartIndex, iEndIndex);

        #endregion

        #region Build DataSource

        DataTable RelationshipListData = new DataTable();
        RelationshipListData.Columns.Add("RelContactID", typeof(int));
        RelationshipListData.Columns.Add("ContactName", typeof(string));
        RelationshipListData.Columns.Add("Relationship", typeof(string));
        RelationshipListData.Columns.Add("Direction", typeof(string));

        foreach (RelatedContact RelatedContact1 in RelationshipList)
        {
            DataRow NewRelRow = RelationshipListData.NewRow();
            NewRelRow["RelContactID"] = RelatedContact1.ContactId;
            NewRelRow["ContactName"]  = RelatedContact1.ContactName;
            NewRelRow["Relationship"] = RelatedContact1.Relationship;
            NewRelRow["Direction"]    = RelatedContact1.Direction;

            RelationshipListData.Rows.Add(NewRelRow);
        }

        RelationshipListData.AcceptChanges();

        #endregion

        this.gridRelationshipList.DataSource = RelationshipListData;
        this.gridRelationshipList.DataBind();

        #endregion
    }