【发布时间】:2015-11-19 23:25:24
【问题描述】:
我创建了一个 DataGrid,我从数据库中获取数据并将其放入其中。
所有数据检索都是通过在后面的代码中动态完成的。
这是我的代码的一部分。
SqlConnection con = new SqlConnection("Data Source=PUNUTHL\\SQL;Initial Catalog=mytest;Integrated Security=True");
SqlDataAdapter ad;
DataSet ds = new DataSet();
static DataTable dt = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ad = new SqlDataAdapter("Select * from product",con);
ad.Fill(ds);
dt = ds.Tables[0];
DataGrid1.DataSource = dt;
DataGrid1.DataBind();
}
}
到目前为止,它运行良好。
但我想为那个 DataGrid 添加编辑功能
但根据我的查询,我也采用了“product_ID”值,这些值不能更新。
由于我同时使用“Etid”和“Delete”命令,“prodcut-id”可能是我的第三列,如图所示。
【问题讨论】: