C# 数据绑定后更改Datagridview中的控件

C# 数据绑定后更改Datagridview中的控件,c#,asp.net,sharepoint,C#,Asp.net,Sharepoint,我甚至不确定这是否可行,但假设我获取一个Datatable并将其绑定到DataGridView。是否可以将第3列设置为dropdownlist,而不是显示一些文本? 编辑:类似的问题,我的代码只是抓住了第一个复选框而忽略了所有其他复选框 //Should iterate over every row for(int i = 0; i < GridView1.Rows.Count; i++) { //Grab the checkbox in the row

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

  //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();

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

您可以尝试在sharepoint.stackexchange.com上发布这些内容!谢谢~但现在我对复选框也有类似的问题。我需要遍历GridView中的每一行,并检查是否选中了复选框。但是,如果我选中了多个复选框,它只会抓取第一个复选框。请看我编辑的帖子