We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Message

I do have a GridDataBoundGrid on a form and a combobox cboAccountID. Based on an Account selected in the combobox, I do execute a SELECT and populate a DataTable (columns: ProductID, ProductName) and then say: Me.grdProducts.DataSource = me.dtProducts Me.grdProducts.Refresh If no rows have been fetched, I want to add a new row on the grid, for this particular Account. The only code that I have is in the CurrentCell_Changed event where I say: Me.grdProducts.CurrentCell.ConfirmChanges If I select a ProductID on the grid (from a bounded column) sometimes I get the error: "Column ProductID does not belong to table Table". I am sorry that I don''t provide any code, but in general ... after populating a grid (Zero or more rows) and I want to edit a cell, do I have to bring the grid into an ''Edit mode'' or somthing like that ? Can you provide a sample with some code. Thank you !

5 Replies

AD Administrator Syncfusion Team February 3, 2004 02:39 PM UTC

The AddNew row normally shows up by default unless you have disabled it. Before I do a sample, can you try adding Me.grdProducts.DataSource = Nothing before your call to Me.grdProducts.DataSource = me.dtProducts to see if that makes this problem go away. Also if you have explicitly added GridBoundColumns, you should try calling grid.GridBoundColumns.Clear after setting the DataSource to Nothing. Do you want to always see the add new row, or only when the datatable is empty?


SA Steli Andrei February 3, 2004 03:30 PM UTC

Thank you for your replay ! No, it still does not work. So, to recall: I did create a DataSet at design time, with a DataTable in it. Set the DataSource of the grid to this DataTable and then go and set the GridBoundColumns. The problem is that after a SELECT query, if no rows in the DataTable and if I try to add a new product (add new row by typing in something directly on the grid) I get the error. As soon as I select something in the first colum (since it''s a GridListControl bounded column), I get the error: "Column ProductID does not belong to table Table". I get this error, right when I try to execute: Me.grdData.CurrentCell.ConfirmChanges - and I am doing this, in order to grab the ProuctID selected. I wrote a message in the Output window right before this statement, and the column ProductID is part of the table. I did what you said: set DataSource first to Nothing. Also call: GridBoundColumns.Clear, although after calling this I have to re-set all the bounded column along with their DataSources at run time. Still, error shows up. >Your question: Do you want to always see the add new row, or only when the datatable is empty? Response: When no data fetched, you can see an empty row on the grid, and that''s what I want. As soon as you try to edit it, a new row gets added (it''s OK) but when I am done editing the first cell, the error message pops up.


AD Administrator Syncfusion Team February 3, 2004 04:54 PM UTC

Can you attached a sample using the Northwind database that ships with VS.NET so I can see the problem here?


SA Steli Andrei February 4, 2004 01:02 PM UTC

Hei Clay, here you have the sample. Please extract the project and read ReadMe.txt. Thank you ! Waiting for you solution. >Can you attached a sample using the Northwind database that ships with VS.NET so I can see the problem here? Test_768.zip


AD Administrator Syncfusion Team February 4, 2004 02:36 PM UTC

What version of our products are you using? I tried your sample with both the 2021 beta and the 1.6.1.8 version, and did not see the problem. I typed 10 into the combobox, clicked on the empty cell under ProductID, typed 1, and then tabbed to next cell without seeing any problem. Should I be doing something else?

Loader.
Live Chat Icon For mobile
Up arrow icon