private void DisplayData() { //[A] 넘겨온 Id 값에 해당하는 레코드 하나 읽어서 모델 클래스에 바인딩 var model = new ArticleBase(); if (AccountHandler.HasGroup("Administrators")) { model = _repository.GetByIdAdmin(Convert.ToInt32(_Id)); } else { model = _repository.GetById(Convert.ToInt32(_Id), _userName); } //[B] 각각의 항목을 컨트롤(레이블, 텍스트박스, ...)에 출력 lblNum.Text = _Id.ToString(); // 번호 lblName.Text = model.Name; // 이름 lblEmail.Text = String.Format("<a href=\"mailto:{0}\">{0}</a>", model.Email); lblTitle.Text = model.Title; lblReadCount.Text = model.ReadCount.ToString(); lblHomepage.Text = String.Format("<a href=\"{0}\" target=\"_blank\">{0}</a>", model.Homepage); lblPostDate.Text = model.PostDate.ToString(); lblPostIp.Text = model.PostIp; //[C] 인코딩 방식에 따른 데이터 출력 string content = model.Content; // 내용 string strEncoding = model.Encoding; if (strEncoding == "Text") // Text: 소스 그대로 표현 { lblContent.Text = HtmlUtility.EncodeWithTabAndSpace(content); } else if (strEncoding == "Mixed") // Mixed: 엔터처리만 { lblContent.Text = content.Replace("\r\n", "<br />"); } else // HTML: HTML 형식으로 출력 { lblContent.Text = content; // 변환없음 } //[D] 파일 다운로드 링크 만들기 if (model.FileName.Length > 1) { lblFile.Text = String.Format( "<a href='./BoardDown.aspx?Id={0}'>" + "{1}{2} / 전송수: {3}</a>", model.Id, "<img src=\"/images/ext/ext_zip.gif\" border=\"0\">", model.FileName, model.DownCount); if (BoardLibrary.IsPhoto(model.FileName)) { ltrImage.Text = "<img src=\'ImageDown.aspx?FileName=" + $"{Server.UrlEncode(model.FileName)}\' class=\"img-fluid rounded\">"; } } else { lblFile.Text = "(업로드된 파일이 없습니다.)"; } }
protected void btnCompare_Click(object sender, EventArgs e) { List <string> checkedDatas = new List <string>(); foreach (GridViewRow row in ctlBoardList.Rows) { if (row.RowType == DataControlRowType.DataRow) { CheckBox chk = (row.FindControl("chkSelect") as CheckBox); HiddenField hdn = (row.FindControl("hdnSelect") as HiddenField); if (chk.Checked) { checkedDatas.Add(hdn.Value); } } } //// 선택한 체크박스 정보를 배열로 받기 //string[] checks = Request.Form.GetValues("chkSelect"); //if (checks != null) //{ // // 문자열 배열을 정수형 배열로 변경 // int[] intChecks = Array.ConvertAll(checks, int.Parse); // // TODO: intChecks 배열을에 해당하는 데이터를 읽어오기 // for (int i = 0; i < intChecks.Length; i++) // { // var record = _repository.GetByIdAdmin(intChecks[i]); // Model.Add(new CompareReportViewModel { // Title = record.Title, ReadCount = record.ReadCount, CommentCount = record.CommentCount, DownCount = record.DownCount }); // } //} foreach (var item in checkedDatas) { var record = _repository.GetByIdAdmin(Convert.ToInt32(item)); Model.Add(new CompareReportViewModel { Title = record.Title, ReadCount = record.ReadCount, CommentCount = record.CommentCount, DownCount = record.DownCount }); } ChartLabels = string.Join(",", Model.Select(m => $"\"{m.Title}\"").ToArray()); if (lstCompareCondition.SelectedValue == "0") { ChartTitle = "조회수"; ChartDatas = string.Join(",", Model.Select(m => m.ReadCount).ToArray()); } else if (lstCompareCondition.SelectedValue == "1") { ChartTitle = "다운수"; ChartDatas = string.Join(",", Model.Select(m => m.DownCount).ToArray()); } else { ChartTitle = "댓글수"; ChartDatas = string.Join(",", Model.Select(m => m.CommentCount).ToArray()); } ctlSelectedData.DataSource = Model; ctlSelectedData.DataBind(); }