DataGrid data retreival

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();

}
 
F

Frank Oquendo

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)
 
F

Frank Oquendo

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,814
Latest member
SpicetreeDigital

Latest Threads

Top