示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lblNoGroups.Visible = false;

            /* Get Start Index */
            try
            {
                startIndex = Int32.Parse(Request.Params.Get("startIndex"));
            }
            catch (ArgumentNullException)
            {
                startIndex = 0;
            }

            /* Get Count */
            try
            {
                count = Int32.Parse(Request.Params.Get("count"));
            }
            catch (ArgumentNullException)
            {
                count = Settings.Default.PracticaMaD_defaultCount;
            }

            /* Get the Service */
            IUnityContainer container =
                (IUnityContainer)HttpContext.Current.
                    Application["unityContainer"];
            groupService =
                container.Resolve<IUserGroupService>();

            /* Get Events Info */
            if (SessionManager.IsUserAuthenticated(Context))
            {
                userId = SessionManager.GetUserSession(Context).UserProfileId;
            }

            GroupBlock groupBlock =
                groupService.GetGroupsByUser(userId, startIndex, count);

            if (groupBlock.Groups.Count == 0)
            {
                lblNoGroups.Visible = true;
                return;
            }

            gvMyGroups.DataSource = groupBlock.Groups;
            gvMyGroups.DataBind();

            /* "Previous" link */
            if ((startIndex - count) >= 0)
            {
                String url =
                    Settings.Default.PracticaMaD_applicationURL +
                    "Pages/Group/SeeMyGroups.aspx" +
                    "?startIndex=" + (startIndex - count) + "&count=" +
                    count;

                this.lnkPrevious.NavigateUrl =
                    Response.ApplyAppPathModifier(url);
                this.lnkPrevious.Visible = true;
            }

            /* "Next" link */
            if (groupBlock.ExistMoreGroups)
            {
                String url =
                    Settings.Default.PracticaMaD_applicationURL +
                    "Pages/Group/SeeMyGroups.aspx" +
                    "?startIndex=" + (startIndex + count) + "&count=" +
                    count;

                this.lnkNext.NavigateUrl =
                    Response.ApplyAppPathModifier(url);
                this.lnkNext.Visible = true;
            }
        }