By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,177 Members | 1,111 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,177 IT Pros & Developers. It's quick & easy.

Updating a Datagrid

P: n/a
Have two tables that have a FK relationship on ID column.

Have one datagrid that displays all of the columns of both tables.

What's the best approach on updating a row from the datagrid back to the

I've used the following code for the DataGird1_UpdateCommand

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

TextBox tbSales = (TextBox)e.Item.Cells[1].Controls[0];

string stSale = tbSales.Text;

string sql = "update table1 set Sale = '" + stSale + "' where ID= " + key;

OracleCommand cmd = new OracleCommand(sql,oracleConnection1);
DataGrid1.EditItemIndex = -1;
It doesn't do a great job of updating from the datagrid to the database.
Especially if you have two tables together in one datagrid. I'm looking for a
better approach on updating.

Another way was to use the DataSet:

DataSet1.DBTableRow row;

row = dataSet11.DBTable.FindByID(int.Parse(key));

row.SALE = stSale;
Does going the route of option2 offer better performance OR is there a
better way to update the datagrid than the above options? If you could show
some sample c# code that would be appreciated.

Any suggestions would be appreciated.


Jul 26 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.