Example #1
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="c"></param>
    protected void BindViewData(Control c)
    {
        //  return;
        PermissionsManager permManager = new PermissionsManager();
        string             username    = HttpContext.Current.User.Identity.Name;

        //You gotta love how FindControl isn't recursive...
        DataList list = (DataList)c.FindControl("RotatorLayoutTable")
                        .FindControl("RotatorListViewRow")
                        .FindControl("RotatorListViewColumn")
                        .FindControl("RotatorListView");

        ISearchProxy permissionsHonoringProxy = new DataAccessFactory().CreateSearchProxy(HttpContext.Current.User.Identity.Name);

        switch (c.ID)
        {
        case "HighestRatedRotator":
            list.DataSource = permissionsHonoringProxy.GetByRating(4);
            break;

        case "MostPopularRotator":
            list.DataSource = permissionsHonoringProxy.GetByViews(4);
            break;

        case "RecentlyUpdatedRotator":
            list.DataSource = permissionsHonoringProxy.GetByLastUpdated(4);
            break;

        case "RandomRotator":
            list.DataSource = permissionsHonoringProxy.GetByRandom(4);
            break;

        default:
            throw new Exception("No control '" + c.ID + "' could be found to bind data to.");
        }
        list.DataBind();
        permissionsHonoringProxy.Dispose();
        permManager.Dispose();
    }