Hello,
I am trying to write an INSERT, UPDATE, and DELETE in the pop-up editor of an ASPxGridView, but everytime I try to enter multiple statements into the query box it says "SQL Syntax Errors Encountered: Unable to parse query text.
Can you please show me an example of how to write multiple table INSERT, UPDATE, and DELETE statements that will run in the Custom SQL statement query window of the smart tag for the ASPxGridView?
Please paste any examples into the body of your post, because due to network security issues where I work, I cannont open attachments.
Thanks,
Jonathan
Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Hello Jonathan,
Thank you for the question. Can you please clarify how you add multiple update statements? I assume that you modify the datasource UpdateCommand/InsertCommand properties via the default dialog window. And, the exception might be thrown by the datasource itself. Is the issue still reproducible even with a standard asp:GridView control?
Possible solutions:
protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { datasource.UpdateCommand = "UPDATE ....."; datasource.Update(...); datasource.UpdateCommand = "UPDATE ....."; datasource.Update(...); datasource.UpdateCommand = "UPDATE ....."; datasource.Update(...); e.Cancel = true; ASPxGridView1.CancelEdit(); }
Does this make sense for you?
Thanks,
Vest
Thanks for the quick response. I see how you're saying to insert and update witht the row event handlers (RowInserting, RowUpdating, RowDeleting). If I used that method would I leave the INSERT, UPDATE, and DELETE tabs within the "custom sql querry" text box of the smart tag for the ASPxGridView blank and just put the SELECT statement under the SELECT tab of the "custom sql querry" text box of the smart tag for the ASPxGridView?
How do I assign the fields in the popup editor of the GridView to associate with the various statements in the Event Handlers and then update/insert into the database?
Thanks,
Jonathan
Hi Jonathan:
For example, if a data source has a "ProductName" field, you can get the corresponding new value as follows:
string newProduct = e.NewValues["ProductName"].ToString();
If you use editors in template containers of the ASPxGridView and need to bind them to the datasource fields, you can use a binding expression. For example:
<dxwgv:GridViewDataColumn FieldName="ProductName" VisibleIndex="8" Width="15%">
<DataItemTemplate>
<dxe:ASPxTextBox ID="templateBox" runat="server" Text='<%#Bind("ProductName")%>'>
</dxe:ASPxTextBox>
</DataItemTemplate>
</dxwgv:GridViewDataColumn>
Thanks
Kate.
I'm trying to do what you suggested that I do, but when I click on the "New" button to Insert a new row, I get the following error:
A primary key field specified via the KeyFieldName property is not found in the underlying data source. Make sure the field name is spelled correctly. Pay attention to the character case.
Ordinarily, I would put the primary key of the table I was reading from in the KeyFieldName with no problem, but since I am doing a multiple table join SELECT statement and there are no relationships among all the tables in my join, I have no real KeyFieldName. How do I handle this problem?
Thanks,
Jonathan
Hi Jonathan:
I'm afraid, the ASPxGridView requires the KeyFieldName if you perform editing/inserting/deleting operations. This property isn't related to the real key field in a data source and you can set the FieldName of ANY existing data column of the grid as the KeyFieldName.
The only requirement is that this field should contain unique values for each record.
Thanks
Kate.