简体   繁体   中英

Can't edit DataGridView cell in C#

I have a datagridview in Windows Forms C# application. It's datasource is DataSet, which has TableAdapter in it. The SQL method that gets the results has a couple INNER JOINs in it. The data is shown in the gridview, but I have a field there that I want to update. But, it's readonly in the gridview. The readonly value to that cell is set to false. I've read somewhere that my datasource is not updatable and that is the reason why the gridview control is not letting me to update it. But I have to update it. Do you have any solution to this?

This is probably due to using the TableAdapter with joins - the TableAdapter wizard is not able to automatically generate the Insert, Update and Delete commands when using joins.

You can verify if this is the case by looking at the properties of the TableAdapter in the dataset designer - the commands will show (None).

Here is a tutorial on adding these commands to a TableAdapter: http://www.asp.net/data-access/tutorials/updating-the-tableadapter-to-use-joins-vb

Personally, I prefer to use a custom dataaccess layer, doing away with the TableAdapter and its autogenerated code entirely.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM