1using System;
2using System.Data;
3using System.Web.UI.WebControls;
4using Microsoft.Practices.EnterpriseLibrary.Data;
5
6public partial class Basic_ListControl : System.Web.UI.UserControl ...{
7 protected void Page_Load(object sender, EventArgs e) ...{
8 DisplayData();
9 }
10 private void DisplayData() ...{
11 this.ctlBasicList.DataSource =
12 DatabaseFactory.CreateDatabase(
13 "ConnectionString").ExecuteDataSet(
14 CommandType.StoredProcedure, "ListBasic");
15 this.ctlBasicList.DataBind();
16 }
17 protected void btnWrite_Click(object sender, EventArgs e) ...{
18 Response.Redirect("Write.aspx");// 글 쓰기 페이지로 이동
19 }
20 protected void btnSearch_Click(object sender, EventArgs e) ...{
21 // 검색 페이지에 필드명과 검색어 전달
22 string strUrl = String.Format(
23 "Search.aspx?SearchField={0}&SearchQuery={1}"
24 , lstSearchField.SelectedValue
25 , Server.UrlEncode(txtSearchQuery.Text));
26 Response.Redirect(strUrl);
27 }
28 protected void ctlBasicList_PageIndexChanging(
29 object sender, GridViewPageEventArgs e) ...{
30 this.ctlBasicList.PageIndex = e.NewPageIndex; // 페이지 지정
31 DisplayData(); // 다시 출력
32 }
33}
34