110,825
社区成员
![](https://csdnimg.cn/release/cmsfe/public/img/topic.427195d5.png)
![](https://csdnimg.cn/release/cmsfe/public/img/me.40a70ab0.png)
![](https://csdnimg.cn/release/cmsfe/public/img/task.87b52881.png)
![](https://csdnimg.cn/release/cmsfe/public/img/share-circle.3e0b7822.png)
DateTime.MinValue;
//建一个datatable结构
DataTable dt = new DataTable();
dt.Columns.Add("ID", typeof(string));
dt.Columns.Add("name", typeof(string));
dt.Columns.Add("time", typeof(DateTime));
dt.Rows.Add("a", "aa",null);//证实用null是可以的,不知道楼主是怎样用
dt.Rows.Add("b", "cc",DateTime.Now);
dt.Rows.Add("e", "ee",DateTime.Now);
dt.Rows.Add("d", "ff",DateTime.Now);
GridView1.DataSource = dt;
GridView1.DataBind();
SqlDataAdapter da = new SqlDataAdapter(cmd);
SqlCommandBuilder bld = new SqlCommandBuilder(da);
bld.ConflictOption = ConflictOption.OverwriteChanges;
for (int j = 0; j < bld.GetInsertCommand().Parameters.Count; j++)
{
bld.GetInsertCommand().Parameters[j].IsNullable = true;
}
for (int j = 0; j < bld.GetUpdateCommand().Parameters.Count; j++)
{
bld.GetUpdateCommand().Parameters[j].IsNullable = true;
}