DataGrid data retreival

  • Thread starter Thread starter Prigozhin Roman
  • Start date Start date
P

Prigozhin Roman

I'm trying to retreive data from DataGrid on my form and update dataset.
Problem is that it returns data without my changes.
((TextBox)e.Item.Cells[0].Controls[0]).Text; returns
unchanged values. Strange..

Here is where I'm calling it from :
private void DataGrid1_UpdateCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)

{

string key=DataGrid1.DataKeys[e.Item.ItemIndex].ToString();

DataSet1.EmployeesRow r;

r=DataSet1.Employees.FindByEmployeeID( Int32.Parse( key ) );


r.FirstName = ((TextBox)e.Item.Cells[0].Controls[0]).Text;

r.LastName = ((TextBox)e.Item.Cells[1].Controls[0]).Text;



sqlDataAdapter1.Update( DataSet1 );

sqlDataAdapter1.Fill( DataSet1);

DataGrid1.EditItemIndex=-1;

DataGrid1.DataBind();

}
 
Prigozhin said:
sqlDataAdapter1.Update( DataSet1 );

sqlDataAdapter1.Fill( DataSet1);

Where's the call to AcceptChanges()? And why are you refilling your
DataSet? That step should be unnecessary.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 
BTW, I recently came across a similar problem. I solved mine by calling
DataRow.BeginEdit(), making my changes, calling DataRow.EndEdit() and
updating the database through a DataAdapter.


--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 
Back
Top