後で編集する予定。
################# Default.aspx.cs ################
using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace DataGridInPanel
{
public partial class _Default : System.Web.UI.Page
{
void BindDataGrid( DataView dv )
{
datagrid.DataSource = dv;
datagrid.DataBind();
}
// 表示用のデータソース (DataView) を生成
private DataView CreateDataSource()
{
DataTable dt = new DataTable();
DataRow dr;
dt.Columns.Add(new DataColumn("DropDownList", typeof(string)));
for (int i = 0; i < 5; i++)
{
dr = dt.NewRow();
dr["DropDownList"] = "<select name=\"blood\"><option value=\"A\">A型</option><option value=\"B\">B型</option></select>";
dt.Rows.Add(dr);
}
DataView dv = new DataView(dt);
return dv;
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataView dv = CreateDataSource();
BindDataGrid(dv);
}
}
}
}
################# Default.aspx ################
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="DataGridInPanel._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Panel ID="Panel1" runat="server">
<asp:DataGrid runat="server" ID="datagrid" />
</asp:Panel>
</div>
</form>
</body>
</html>
0 件のコメント:
コメントを投稿