0

我什至不确定这是否可行,但假设我使用了一个 Datatable 并将其绑定到我的 DataGridView。是否可以将第 3 列设置为下拉列表而不是显示一些文本?编辑:类似的问题,我的代码只是抓住第一个选中的复选框并忽略所有其他的?

  //Should iterate over every row      
  for(int i = 0; i < GridView1.Rows.Count; i++)
        {
//Grab the checkbox in the row
            CheckBox chkDelete = (CheckBox) GridView1.Rows[i].FindControl("opCheck");
            if(chkDelete != null)
            {
//If the checkbox exists, see if it is checked
                if(chkDelete.Checked)
                {
 //If it is checked, write out the SQL command and delete it from the database
                    //Write out the SQL command to delete whatever is checked
                    command = "SQL_STATEMENT";


                    cmd = new OleDbCommand(command, con);
                    //Execute the command and fill the data set
                    cmd.ExecuteNonQuery();

                    BindData();
                    cmd.Dispose();
                }
            }

        }
            con.Dispose();
            con.Close();
4

1 回答 1

0

当然。如果您对每一列使用,则您可以更好地控制ItemTemplate每一列。然后将参数设置OnDataBinding为为每一行填充该列的方法。使用模板允许您为给定列定义几乎任何 ASP 或 HTML 元素。

于 2012-10-17T23:50:52.200 回答