K
Kostia
Hi, so I am using built in Edit, Delete, Update i.e.
OnEditCommand="DataGrid1_Edit" OnUpdateCommand="DataGrid1_Update" with
handler
question below in regards to the actual update after edit
//called by the handler deletes row no problem and updates DB no
problem
private void DeleteItem(DataGridCommandEventArgs e)
{
DataRow dr = dsEmployees1.Tables["Employees"].Rows[e.Item.ItemIndex];
dr.Delete();
sqlDataAdapter1.Update(dsEmployees1, "Employees");
DataGrid1.EditItemIndex = -1;
DataGrid1.DataBind();
}
public void DataGrid1_Edit(Object sender, DataGridCommandEventArgs E)
{
DataGrid1.EditItemIndex = (int)E.Item.ItemIndex;
DataGrid1.DataBind();
}
//NOW WHAT DO I NEED TO DO HERE TO ACTUALLY UPDATE THE ROW?
//IS THE ONLY WAY TO DO IT IS by getting individual column values and
//constructing SQL statement? IS there a way to call some kind of
update to accept and commit entered changes? done through Edit?
public void DataGrid1_Update(Object sender, DataGridCommandEventArgs
E)
{
DataGrid1.EditItemIndex = (int)E.Item.ItemIndex;
DataRow dr = dsEmployees1.Tables["Employees"].Rows[DataGrid1.EditItemIndex];
sqlDataAdapter1.Update(dsEmployees1, "Employees");
// Rebind the data source to refresh the DataGrid control.
DataGrid1.EditItemIndex = -1;
DataGrid1.DataBind();
}
OnEditCommand="DataGrid1_Edit" OnUpdateCommand="DataGrid1_Update" with
handler
question below in regards to the actual update after edit
//called by the handler deletes row no problem and updates DB no
problem
private void DeleteItem(DataGridCommandEventArgs e)
{
DataRow dr = dsEmployees1.Tables["Employees"].Rows[e.Item.ItemIndex];
dr.Delete();
sqlDataAdapter1.Update(dsEmployees1, "Employees");
DataGrid1.EditItemIndex = -1;
DataGrid1.DataBind();
}
public void DataGrid1_Edit(Object sender, DataGridCommandEventArgs E)
{
DataGrid1.EditItemIndex = (int)E.Item.ItemIndex;
DataGrid1.DataBind();
}
//NOW WHAT DO I NEED TO DO HERE TO ACTUALLY UPDATE THE ROW?
//IS THE ONLY WAY TO DO IT IS by getting individual column values and
//constructing SQL statement? IS there a way to call some kind of
update to accept and commit entered changes? done through Edit?
public void DataGrid1_Update(Object sender, DataGridCommandEventArgs
E)
{
DataGrid1.EditItemIndex = (int)E.Item.ItemIndex;
DataRow dr = dsEmployees1.Tables["Employees"].Rows[DataGrid1.EditItemIndex];
sqlDataAdapter1.Update(dsEmployees1, "Employees");
// Rebind the data source to refresh the DataGrid control.
DataGrid1.EditItemIndex = -1;
DataGrid1.DataBind();
}