Example #1
0
        public void BindPager()
        {
            panelPager.Controls.Clear();

            var manager = new NotesManagerBusinessLogic();
            var countOfNotes = manager.GetNotesCount();
            
            var countOfPages = countOfNotes%10 == 0 ? countOfNotes/10 : countOfNotes/10 + 1;

            if(countOfPages <= 1)
                return;

            for (var i = 1; i < countOfPages + 1; i++)
            {
                _linkButton = new LinkButton {ID = LinkId + i, Text = i.ToString()};
                
                if (CurrentPage == i)
                    _linkButton.BackColor = Color.DarkGray; 

                PanelPager.Controls.Add(_linkButton);

                var spacer = new Label { Text = "&nbsp;" };

                PanelPager.Controls.Add(spacer);
            }
        }
        public void BindNotes()
        {
            var manager = new NotesManagerBusinessLogic();
            var data = manager.GetNotes(_currentPage);

            Repeater1.DataSource = data;
            Repeater1.DataBind();
        }
        public void ShowNote(int noteId)
        {
            _noteId = noteId;

            var manager = new NotesManagerBusinessLogic();
            var note = manager.GetNote(_noteId);

            LabelName.Text = note.Name;
            LiteralData.Text = note.HTML;
        }
        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName != "delete") 
                return;
            
            var noteId = int.Parse(e.CommandArgument.ToString());

            try
            {
                var manager = new NotesManagerBusinessLogic();
                manager.DeleteNote(noteId);

                PagerControl1.CurrentPage = _currentPage;
                PagerControl1.BindPager();
                AddEventClick();

                BindNotes();
            }
            catch (InvalidOperationException exception)
            {
                Labelerror.Text = exception.Message;
            }
        }