Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        _muc   = Membership.GetUser();
        _blogs = new List <IITCourse.Blog.Blog>();
        _labelNoOfResponses = (Label)ListViewBlogs.FindControl("labelNoOfResponses");
        if (!(IsPostBack))
        {
            _blogs = BlogService.GetBlogs();
            ListViewBlogs.DataSource = _blogs;
            ListViewBlogs.DataBind();
            List <string> dropDownItemToAdd = BlogService.GetNamesOfAllUser();

            dropDownItemToAdd.Insert(0, "All Users");
            ddUsers.DataSource = dropDownItemToAdd;
            ddUsers.DataBind();
        }
    }
Пример #2
0
    protected void ddUsers_SelectedIndexChanged(object sender, EventArgs e)
    {
        HyperLink hyperLinkEditBlog      = (HyperLink)ListViewBlogs.FindControl("HyperLinkEditBlog");
        List <IITCourse.Blog.Blog> blogs = new List <IITCourse.Blog.Blog>();

        if (ddUsers.SelectedValue == "All Users")
        {
            blogs = BlogService.GetBlogs();
        }
        else
        {
            if (Roles.GetRolesForUser(ddUsers.SelectedValue).Contains("Admin"))
            {
                hyperLinkEditBlog.Visible = true;
            }
            else
            {
                blogs = BlogService.GetUserSpecificBlogs(ddUsers.SelectedValue);
            }
        }

        ListViewBlogs.DataSource = blogs;
        ListViewBlogs.DataBind();
    }