1using System;
2using System.Data;
3using Microsoft.Practices.EnterpriseLibrary.Data;
4using System.Web.UI.WebControls;
5
6public partial class Upload_ViewControl : System.Web.UI.UserControl
7...{
8 protected void Page_Load(object sender, EventArgs e)
9 ...{
10 if (String.IsNullOrEmpty(Request["Num"]))
11 ...{
12 Response.Write("잘못된 요청입니다.");
13 Response.End();
14 }
15 else
16 ...{
17 DisplayData();
18 }
19 }
20 private void DisplayData()
21 ...{
22 using (IDataReader dr = DatabaseFactory.CreateDatabase(
23 "ConnectionString").ExecuteReader(
24 "ViewUpload", Request["Num"]))
25 ...{
26 while (dr.Read())
27 ...{
28 lblNum.Text = dr[0].ToString();
29 lblName.Text = dr["Name"].ToString();
30 lblEmail.Text = dr.GetString(2);
31 lblTitle.Text = dr["Title"].ToString();
32 lblHomepage.Text = dr["Homepage"].ToString();
33 lblPostDate.Text = dr["PostDate"].ToString();
34 lblReadCount.Text = dr["ReadCount"].ToString();
35 lblPostIP.Text = dr["PostIP"].ToString();
36 lblContent.Text = dr["Content"].ToString();//***
37
38 //[1]
39 lblFileName.Text =
40 String.Format(
41 "<a href='Down.aspx?FileName={0}'>{0}</a> / 다운수 : {1}"
42 , dr["FileName"], dr["DownCount"]);
43 //[2]
44 lnkFileName.Text = dr["FileName"].ToString();
45 lnkFileName.NavigateUrl =
46 String.Format("~/Upload/Down.aspx?FileName={0}"
47 , dr["FileName"]);
48 //[3]
49 //[a] 동적으로 하이퍼링크를 만들어서
50 HyperLink lnk = new HyperLink();
51 lnk.Text = dr["FileName"].ToString();
52 lnk.NavigateUrl =
53 String.Format("~/Upload/Down.aspx?FileName={0}"
54 , dr["FileName"]);
55 //[b] 플레이스홀더 컨트롤에 추가
56 ctlFileName.Controls.Add(lnk);
57 }
58 }
59 }
60 protected void btnModify_Click(object sender, EventArgs e)
61 ...{
62 Response.Redirect("Modify.aspx?Num=" + Request["Num"]);
63 }
64 protected void btnDelete_Click(object sender, EventArgs e)
65 ...{
66 Response.Redirect("Delete.aspx?Num=" + Request["Num"]);
67 }
68 protected void btnList_Click(object sender, EventArgs e)
69 ...{
70 Response.Redirect("List.aspx?Num=" + Request["Num"]);
71 }
72}
73