flnMichael
Programmer
Can somebody please tell me what I have wrong here:
the error is:
Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
KPC_Data_Grid.DataBind();
sqlDataAdapter1.Update(kpC_Data_Set1);
BindGrid();
This is really getting to me...can someone shed some light on this for me???
Thanks
Mike
Code:
private void KPC_Data_Grid_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
sqlDataAdapter1.SelectCommand.Connection.Open();
sqlDataAdapter1.SelectCommand.CommandText = "SELECT name,description,lsl,usl,units FROM KPC where OPID ='" + myOPID + "'";
sqlDataAdapter1.SelectCommand.ExecuteReader();
sqlDataAdapter1.SelectCommand.Connection.Close();
sqlDataAdapter1.Fill(kpC_Data_Set1, "KPC");
sqlDataAdapter1.SelectCommand.Connection.Open();
TextBox name, desc, lsl, usl, unit;
name = (TextBox)e.Item.Cells[2].Controls[0];
desc = (TextBox)e.Item.Cells[3].Controls[0];
lsl = (TextBox)e.Item.Cells[4].Controls[0];
usl = (TextBox)e.Item.Cells[5].Controls[0];
unit = (TextBox)e.Item.Cells[6].Controls[0];
KPC_Data_Set.KPCDataTable myNewTable = kpC_Data_Set1.KPC;
KPC_Data_Set.KPCRow rowToUpdate = (KPC_Data_Set.KPCRow)myNewTable.Rows[e.Item.ItemIndex];
rowToUpdate.name = name.Text;
rowToUpdate.description = desc.Text;
rowToUpdate.lsl = Convert.ToInt32(lsl.Text);
rowToUpdate.usl = Convert.ToInt32(usl.Text);
rowToUpdate.units = unit.Text;
sqlDataAdapter1.SelectCommand.Connection.Close();
KPC_Data_Grid.DataSource = kpC_Data_Set1.KPC.DefaultView;
KPC_Data_Grid.EditItemIndex=-1;
KPC_Data_Grid.DataBind();
sqlDataAdapter1.Update(kpC_Data_Set1);
BindGrid();
}
the error is:
Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
KPC_Data_Grid.DataBind();
sqlDataAdapter1.Update(kpC_Data_Set1);
BindGrid();
This is really getting to me...can someone shed some light on this for me???
Thanks
Mike