This is a migrated thread and some comments may be shown as answers.

[Solved] error in insert or update when " ' quote value "

1 Answer 97 Views
Grid
This is a migrated thread and some comments may be shown as answers.
casa51
Top achievements
Rank 2
casa51 asked on 28 May 2009, 08:54 AM
hi
excuse for my english "am french"

I test your telerik datagrid with usercontrol insert/update/delete exemple
and all work well with simple word
but  when i trie to update a value with ' quote  ex: l'organisation it impossible to send this value.
i think it a concatenation problem

my code

usercontrol.ascx :

 

 

<asp:TextBox ID="AssoPresident" runat="server" Width="260px" Text='<%# DataBinder.Eval( Container, "DataItem.AssoPresident" ) %>'></asp:TextBox> 
 
 
 

default.aspx (code behind) :

 

 

 

Protected Sub RadGrid1_UpdateCommand(ByVal source As ObjectByVal e As GridCommandEventArgs) Handles RadGrid1.UpdateCommand  
        Dim editedItem As GridEditableItem = TryCast(e.Item, GridEditableItem)  
        Dim MyUserControl As UserControl = CType(e.Item.FindControl(GridEditFormItem.EditFormUserControlID), UserControl)  
        'Get the primary key value using the DataKeyValue.       
        Dim AssoID As String = editedItem.OwnerTableView.DataKeyValues(editedItem.ItemIndex)("AssoID").ToString()  
        'Access the textbox from the edit form template and store the values in string variables.       
        'Dim AssoNom As String = (TryCast(editedItem.FindControl("RadTextNom"), RadTextBox)).Text  
        Dim AssoPresident As String = CType(MyUserControl.FindControl("AssoPresident"), TextBox).Text  
        'Dim PetitDescriptif As String = CType(userControl.FindControl("PetitDescriptif"), TextBox).Text  
        Try 
            'Open the SqlConnection       
            SqlConnection.Open()  
            'Update Query to update the Datatable        
            Dim updateQuery As String = "UPDATE association set AssoPresident='" & AssoPresident & "' where AssoID='" & AssoID & "'" 
            SqlCommand.CommandText = updateQuery  
            SqlCommand.Connection = SqlConnection  
            SqlCommand.ExecuteNonQuery()  
            'Close the SqlConnection       
 
 
            SqlConnection.Close()  
        Catch ex As Exception  
            RadGrid1.Controls.Add(New LiteralControl("Unable to update Customers. Reason: " + ex.Message))  
            e.Canceled = True 
        End Try 
    End Sub 

 

 



can you help me I don't see where is the error.




 

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 01 Jun 2009, 08:32 AM
Hello Dartus,

May I suggest you examine this online demo? Please verify that the get the correct values from the TextBox control. If the value is correct, you can check whether the problem is in the custom update of the data.

Regards,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
casa51
Top achievements
Rank 2
Answers by
Georgi Krustev
Telerik team
Share this question
or