开发者

Can't edit Datagridview in C# when using UNION

I have a Windows Form Application with Datagridview. Enable editing is TRUE, but I can't edit the fields inside the datagrid. I'm 开发者_开发百科using datasource which has SQL UNION. When using the query without the UNION, it's fine.

I'm talking about not be able to even start changing the fields in the grid with F2 or double click. I have to use union here, but it seems to be a problem and I can't find solution...


A little more code would help, but it seems as though your SQL Datasource is smart enough to know that the query is readonly.

As you said, when you take off the union, it works fine. So setting the grid to a datasource of

SELECT FOO FROM MyTable

Could cause a corresponding update query of UPDATE MyTable to be created. No such corresponding query exists with a

SELECT FOO FROM MyTable UNION SELECT FOO FROM MyOtherTable

So the grid is probably smart enough to prevent you from editing those fields. This is the same behavior when you bind a DGV to a collection of C# Objects; those columns that are read only are never able to be edited (how could they);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜