예제 #1
0
        protected void BindDataCommentList()
        {
            IEnumerable <CommentDto> comments = CommentService.GetIndependentComments(Convert.ToInt32(Request.QueryString["PostId"]));

            DataTable dt = new DataTable();

            dt.Columns.Add("CommentId");
            dt.Columns.Add("CommentText");
            dt.Columns.Add("CreationDate");
            dt.Columns.Add("UserName");


            foreach (CommentDto comment in comments)
            {
                DataRow newRow = dt.NewRow();
                newRow["CommentId"]    = comment.Id;
                newRow["CommentText"]  = comment.CommentText;
                newRow["CreationDate"] = CommentDateGenerator.GetDateString(comment.CreationDate);
                newRow["UserName"]     = comment.UserName;
                dt.Rows.Add(newRow);
            }

            CommentGridview.DataSource = dt;
            CommentGridview.DataBind();
        }
예제 #2
0
        protected void BindDataDependentCommentList(GridView inputGridView)
        {
            if (inputGridView != null)
            {
                HiddenField hfCommentId = (HiddenField)inputGridView.Parent.FindControl("CommentId");
                if ((hfCommentId.Value != null) & (hfCommentId.Value != ""))
                {
                    IEnumerable <CommentDto> comments = CommentService.GetCommentAnswers(Convert.ToInt32(hfCommentId.Value));

                    DataTable dt = new DataTable();
                    dt.Columns.Add("CommentId");
                    dt.Columns.Add("CommentText");
                    dt.Columns.Add("CreationDate");
                    dt.Columns.Add("UserName");


                    foreach (CommentDto comment in comments)
                    {
                        DataRow newRow = dt.NewRow();
                        newRow["CommentId"]    = comment.Id;
                        newRow["CommentText"]  = comment.CommentText;
                        newRow["CreationDate"] = CommentDateGenerator.GetDateString(comment.CreationDate);
                        newRow["UserName"]     = comment.UserName;
                        dt.Rows.Add(newRow);
                    }

                    inputGridView.DataSource = dt;
                    inputGridView.DataBind();
                }
            }
        }