頁面TestCheckBox
private void Page_Load(object sender
{
AddColumnToDataGrid();
BindData();
}
private void AddColumnToDataGrid()
{ //添加一列復選框
CheckBoxColumn checkCol = new CheckBoxColumn(true
checkCol
checkCol
//添加復選框的事件
checkCol
//添加到myDataGrid控件中
myDataGrid
}
private void BindData()
{
//綁定myDataGrid控件的數據
myDataGrid
myDataGrid
}
函數BindData()調用函數CreateDataSource()創建myDataGrid控件的數據源dataTable
private DataTable CreateDataSource()
{
//創建數據表及其列
DataTable dataTable = new DataTable(
dataTable
dataTable
dataTable
dataTable
//添加五行數據
for(int i =
{ //添加一行數據
DataRow row = dataTable
foreach(DataColumn column in dataTable
{ //添加CheckBox控件的數據
if(column
{
[
From:http://tw.wingwit.com/Article/program/net/201311/15043.html