/* ****************************************************** */
데이타 테이블로 데이타리스트, 그리드뷰 채우기
/* ****************************************************** */
protected void Page_Load(object sender, EventArgs e)
{
DataRow workRow;
DataTable workTable = new DataTable();
workTable.Columns.Add("title");
workTable.Columns.Add("content");
for (int i = 0; i <= 5; i++)
{
workRow = workTable.NewRow();
workRow[0] = i;
workRow[1] = "CustName" + i.ToString();
workTable.Rows.Add(workRow);
}
this.DataListTemp.DataSource = workTable;
DataListTemp.DataBind();
}
[펌] ^^;;
/* ************************************************************************* */
DataTable을 이용한 DorpDown 셋팅
/* ************************************************************************* */
#region setSearchDropDown() : COMBO BOX 셋팅
private void setSearchDDL()
{
ddlSearch.DataSource = CreateSearchDataSource();
ddlSearch.DataTextField = "SearchTxtList";
ddlSearch.DataValueField = "SearchValueList";
ddlSearch.DataBind();
if (!IsPostBack) ddlSearch.SelectedIndex = 0;
}
ICollection CreateSearchDataSource()
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("SearchTxtList", typeof(String)));
dt.Columns.Add(new DataColumn("SearchValueList", typeof(String)));
// Populate the table with sample values.
dt.Rows.Add(CreateRow("All", "All", dt));
dt.Rows.Add(CreateRow("양식", "format", dt));
dt.Rows.Add(CreateRow("부서", "station", dt));
dt.Rows.Add(CreateRow("이름", "name", dt));
dt.Rows.Add(CreateRow("사번", "num", dt));
// Create a DataView from the DataTable to act as the data source
// for the DropDownList control.
DataView dv = new DataView(dt);
return dv;
}
DataRow CreateRow(String Text, String Value, DataTable dt)
{
DataRow dr = dt.NewRow();
dr[0] = Text;
dr[1] = Value;
return dr;
}
#endregion
[펌] http://blog.naver.com/newcomsa/30021491682