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

Delete not working in RadGrid

6 Answers 307 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jorge Saa-Gerbier
Top achievements
Rank 1
Jorge Saa-Gerbier asked on 10 Feb 2011, 09:03 PM

I have problems to erase a register from a RADGRID, associated to a SessionDataSource, which I use temporarily, playing the role of a “recipient“ ( just insert and delete).

 

The code the .aspx for the SessionDataSource is as below:

<sds:SessionDataSource 
    DisplayWarning                  = "False"    
    PrimaryKeyFields                = "dp_key"
    ProviderName                    = "System.Data.SqlClient"
    ID                                          = "devis" 
    runat                                     = "server" 
    ConnectionString               = "<%$ ConnectionStrings:string_Connection %>" 
    ConflictDetection               = "CompareAllValues" 
    OldValuesParameterFormatString  = "original_{0}"
  
    SelectCommand="SELECT * FROM [devis] ORDER BY dp_key"
    DeleteCommand="DELETE   FROM [devis] WHERE [dp_key] = ?"
    InsertCommand="INSERT   INTO devis(dp_codeprd, dp_nombre, dp_convives, dp_prixs, dp_prixs_unitaire) VALUES (?, ?, ?, ?, ? )" 
    >
    <DeleteParameters>
        <asp:Parameter Name="original_dp_key"             Type="Int32"   />
    </DeleteParameters>
  
    <InsertParameters>
        <asp:Parameter Name="dp_codeprd"                   Type="String"   />
        <asp:Parameter Name="dp_nombre"                    Type="String"   />
        <asp:Parameter Name="dp_convives"                   Type="Int16"    />
        <asp:Parameter Name="dp_prixs"                          Type="Decimal"  />
        <asp:Parameter Name="dp_prixs_unitaire"           Type="Decimal"  />
    </InsertParameters>
  
</sds:SessionDataSource>

The code the .aspx for RadGrid is as below:

<telerik:RadGrid 
        ShowFooter              = "false"
        ID                      = "devis_prd" 
        runat                   = "server"
        DataSourceID            = "devis" 
        Width                   = "100%" 
        AllowPaging             = "True" 
        PageSize                = "10" 
        AllowSorting            = "false"
        GridLines               = "None"
           
        AllowAutomaticDeletes   = "True" 
        AllowAutomaticInserts   = "True"
        AllowAutomaticUpdates   = "True" 
        onitemdatabound         = "devis_prd_ItemDataBound" 
    >
    <HeaderContextMenu EnableTheming="True">
        <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
    </HeaderContextMenu>
    <MasterTableView 
        AutoGenerateColumns="False" 
        CommandItemDisplay="None" 
        CurrentResetPageIndexAction="SetPageIndexToFirst" 
        DataKeyNames="dp_key, dp_codeprd, dp_nombre, dp_convives, dp_prixs, dp_prixs_unitaire" 
        HorizontalAlign="NotSet" Name="devis_prd" 
        NoDetailRecordsText="Aucun produit sélectionné !" 
        NoMasterRecordsText="Votre devis est vide !" Width="100%">
        <Columns>
            <telerik:GridBoundColumn DataField="dp_key" DataType="System.Int32" 
                HeaderText="Id " ReadOnly="True" SortExpression="dp_key" UniqueName="dp_key" 
                Visible="false">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="dp_CodePrd" 
                DataFormatString="{0:LLL-LL-000}" DataType="System.String" 
                HeaderText="Code Produit" UniqueName="dp_CodePrd">
                <HeaderStyle HorizontalAlign="Center" />
                <ItemStyle HorizontalAlign="Center" />
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="dp_nombre" DataType="System.String" 
                HeaderText="Nom du Produit" SortExpression="dp_nombre" UniqueName="dp_nombre">
                <HeaderStyle HorizontalAlign="Left" />
                <ItemStyle HorizontalAlign="Left" />
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="dp_convives" DataType="System.Int32" 
                HeaderText="Convives" SortExpression="dp_convives" UniqueName="dp_convives">
                <HeaderStyle HorizontalAlign="Right" />
                <ItemStyle CssClass="monto_grid" />
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="dp_prixs" DataFormatString="{0:C2}" 
                DataType="System.Decimal" HeaderText="Prix de la Paella" 
                SortExpression="dp_prixs" UniqueName="dp_prixs">
                <HeaderStyle HorizontalAlign="Right" />
                <ItemStyle CssClass="monto_grid" />
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="dp_prixs_unitaire" 
                DataFormatString="{0:C2}" DataType="System.Decimal" HeaderStyle-Width="120" 
                HeaderText="Prix unitaire " SortExpression="dp_prixs_unitaire" 
                UniqueName="dp_prixs_unitaire">
                <HeaderStyle HorizontalAlign="Right" />
                <ItemStyle CssClass="monto_grid" />
            </telerik:GridBoundColumn>
            <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" 
                ConfirmDialogType="RadWindow" 
                ConfirmText="Cette action permet de supprimer le produit sélectionné de votre devis. <br/><br/>Etes-vous sûr ? <br/><br/>" 
                Text="Supprimer ce produit" UniqueName="DeleteColumn">
                <HeaderStyle Width="20px" />
                <ItemStyle CssClass="MyImageButton" HorizontalAlign="Center" />
            </telerik:GridButtonColumn>
        </Columns>
    </MasterTableView>
    <PagerStyle Mode="NextPrevAndNumeric" />
</telerik:RadGrid>

The insert I do it with the code behind and it works without any problem:

 

public void Insert_Devis(object source, EventArgs e)
{
    devis.InsertParameters["dp_codeprd"].DefaultValue        = Code_PRD();
    devis.InsertParameters["dp_nombre"].DefaultValue         = Produits_ID.Text;
    devis.InsertParameters["dp_convives"].DefaultValue       = RadComboBox1.Text;
    devis.InsertParameters["dp_prixs"].DefaultValue          = (Convert.ToDouble(RadComboBox1.SelectedValue) * Convert.ToInt16(RadComboBox1.Text)).ToString();
    devis.InsertParameters["dp_prixs_unitaire"].DefaultValue = RadComboBox1.SelectedValue.ToString();
    devis.Insert();
}

But at the moment of deleting a registry from the “recipient” (RadGrid) I get the following message:

Mensaje: Sys.WebForms.PageRequestManagerServerErrorException: Error de sintaxis en la expresión.

Línea: 3

Carácter: 74672

Código: 0

URI: http://subtest.test.com/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl00_RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bAjaxControlToolkit%2c+Version%3d4.1.40412.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d28f01b0e84b6d53e%3aes-ES%3aacfc7575-cdee-46af-964f-5d85d9cdcf92%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%2c+Version%3d2010.3.1109.40%2c+Culture%3dneutral%2c+PublicKeyToken%3d121fae78165ba3d4%3aes-ES%3a30468509-1b07-456a-b5f4-bb35a9cae168%3a16e4e7cd%3a874f8ea2%3af7645509%3a24ee1bba%3af46195d3%3a19620875%3a490a9d4e%3abd8f85e4%3a86526ba7%3ae330518b%3a1e771326%3ac8618e41%3aed16cbdc%3a39040b5c%3af85f9819%3ab7778d6c%3a82923ac3%3bAjaxControlToolkit%2c+Version%3d4.1.40412.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d28f01b0e84b6d53e%3aes-ES%3aacfc7575-cdee-46af-964f-5d85d9cdcf92%3a923aa3cc%3a853c2e0b%3a46f97eb1%3a782b16ab%3a535785ef »

Please help me to solve this problem.

Thanks for your help,
Jorge Saa-Gerbier

6 Answers, 1 is accepted

Sort by
0
Jorge Saa-Gerbier
Top achievements
Rank 1
answered on 10 Feb 2011, 09:34 PM

I have to add that exploring several options (I’ve been trying to find the solution), like for example I have added to RADGRID:

                                OnDeleteCommand         = "devis_prd_DeleteCommand" 

And the code behind is the following:

    protected void devis_prd_DeleteCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
        etapa_02.Alert("Delete..... devis_prd_DeleteCommand");
        GridDataItem item = (GridDataItem)e.Item;
        String keyID = item.OwnerTableView.DataKeyValues[item.ItemIndex]["dp_key"].ToString();
        try
        {
            //Delete command execute   
            devis.DeleteCommand = "DELETE FROM devis Where dp_key = '" + keyID + "'";
            SetMessage("Product with ID " + keyID + " is deleted!");
            etapa_02.Alert("Product with ID " + keyID + " is deleted!");
        }
        catch (Exception ex)
        {
            devis_prd.Controls.Add(new LiteralControl("Unable to delete devis. Reason: " + ex.Message));
            e.Canceled = true;
            SetMessage("Product with ID " + keyID + " cannot be deleted. Reason: " + ex.Message);
            etapa_02.Alert("Product with ID " + keyID + " cannot be deleted. Reason: " + ex.Message); 
        }
    }

 

And the code is never executed, It just gives me the error indicated before.

0
Radoslav
Telerik team
answered on 16 Feb 2011, 09:39 AM
Hello Jorge,

I tried to reproduce the described issue but to no avail. I am sending you a simple example, please check it out and let me know what differs in your case.
Looking forward for your reply.

Kind regards,
Radoslav
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Jorge Saa-Gerbier
Top achievements
Rank 1
answered on 16 Feb 2011, 01:43 PM

Hello Radoslav,

Thanks for answering, I’m a beginner in doing this!

 


I have a detail overlooked, all the above is within a AjaxToolkit:CollapsiblePanelExtender, but finally, as a test, I isolated by reducing the minimum necessary to verify whether there are "still" some inconsistency "AjaxToolkit" ie "stage " at issue now is not within the" CollapsiblePanelExtender ", and yet the problem persists. Be ruled out in principle the problem of "inconsistency". See it in http://paellas.aw-dig.com/depaso/default2.aspx.


 

I also tried different settings in the "RadScriptManager"(the green) and in all I have basically the same error "Sys.WebForms.PageRequestManagerServerErrorException: Syntax error in expression"

    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnableScriptGlobalization="true" EnableScriptCombine="true"

    >

        <Scripts>

            <%-- Load the toolkit MS AJAX scripts instead of those in System.Web.Extensions

            <asp:ScriptReference Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"  Name="MicrosoftAjax.js"         Path="~/Scripts-40412/MicrosoftAjax.js" /> 

            <asp:ScriptReference Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"  Name="MicrosoftAjaxWebForms.js" Path="~/Scripts-40412/MicrosoftAjaxWebForms.js" />   

 

            <asp:ScriptReference Assembly="System.Web.Extensions" Name="MicrosoftAjax.js"           Path="~/Scripts/MicrosoftAjax.js" />

            <asp:ScriptReference Assembly="System.Web.Extensions" Name="MicrosoftAjaxWebForms.js"   Path="~/Scripts/MicrosoftAjaxWebForms.js" />

 

            <asp:ScriptReference Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" Name="MicrosoftAjax.js"         Path="http://ajax.microsoft.com/ajax/4.0/1/MicrosoftAjax.js" />

            <asp:ScriptReference Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" Name="MicrosoftAjaxWebForms.js" Path="http://ajax.microsoft.com/ajax/4.0/1/MicrosoftAjaxWebForms.js" />

 

            <asp:ScriptReference Name="MicrosoftAjax.js"                Path="/jsc/MicrosoftAjax.js" />  

            <asp:ScriptReference Name="MicrosoftAjaxWebForms.js"        Path="/jsc/MicrosoftAjaxWebForms.js" />

 

            <asp:ScriptReference Name="Telerik.Web.UI.Common.Core.js"   Assembly="Telerik.Web.UI" />  

            <asp:ScriptReference Name="Telerik.Web.UI.Common.jQuery.js" Assembly="Telerik.Web.UI" Path="~/common/codigo_scr/jquery-1.4.1.js" />  

            --%>

        </Scripts>

    </telerik:RadScriptManager>

 


I have also updated the RadControls for ASP.NET AJAX Q3 2010 (2010.3.1317) from version 2010.3.1109.

 


With the following definition (without any
Script file) : <telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnableScriptGlobalization="true" EnableScriptCombine="true" />

 

I get the following error (message in Spanish):

Detalles de error de página web

 

Agente de usuario: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; Media Center PC 6.0; .NET4.0C; InfoPath.2; .NET4.0E; .NET CLR 3.5.30729; .NET CLR 3.0.30729)

Fecha: Wed, 16 Feb 2011 11:34:28 UTC

 

Mensaje: Sys.WebForms.PageRequestManagerServerErrorException: Error de sintaxis en la expresión.

Línea: 3

Carácter: 74672

Código: 0

URI: http://paellas.aw-dig.com/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl00_RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bAjaxControlToolkit%2c+Version%3d4.1.40412.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d28f01b0e84b6d53e%3aes-ES%3aacfc7575-cdee-46af-964f-5d85d9cdcf92%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%2c+Version%3d2010.3.1317.40%2c+Culture%3dneutral%2c+PublicKeyToken%3d121fae78165ba3d4%3aes-ES%3a9506cff2-3a86-46c5-b869-6ba1478f3c27%3a16e4e7cd%3af7645509%3a24ee1bba%3a19620875%3a874f8ea2%3af46195d3%3a490a9d4e%3abd8f85e4%3a86526ba7%3aed16cbdc%3a1e771326%3aaa288e2d%3a58366029

 


And changing only:
  <telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnableScriptGlobalization="true" EnableScriptCombine="false" />

 

I get the following error (message in Spanish):

Detalles de error de página web

 

Agente de usuario: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; Media Center PC 6.0; .NET4.0C; InfoPath.2; .NET4.0E; .NET CLR 3.5.30729; .NET CLR 3.0.30729)

Fecha: Wed, 16 Feb 2011 11:36:42 UTC

 

Mensaje: Sys.WebForms.PageRequestManagerServerErrorException: Error de sintaxis en la expresión.

Línea: 938

Carácter: 13

Código: 0

URI: http://paellas.aw-dig.com/ScriptResource.axd?d=u5d75j4b1s2l30Lp3t9ZIhxNiu1W6vt7wWFo-6sODtmAOoAHJgpre_7MBBhv3QBRcVCkT3r7ebUpxVNwA-v9iPt9-0hFGKNOI8ZIq0NbeIlgDOkq366P8KqQ7jputy3qOP2PqtpSrJl1pTvvI1GsTA2&t=ffffffffbd2983fc

 


With the following definition and the files of
ScriptReference got in the last version source of ajaxtoolkit (Version=4.1.40412.0)

    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnableScriptGlobalization="true" EnableScriptCombine="true" >

        <Scripts>

            <asp:ScriptReference Name="MicrosoftAjax.js"                Path="/jsc/MicrosoftAjax.js" />  

            <asp:ScriptReference Name="MicrosoftAjaxWebForms.js"        Path="/jsc/MicrosoftAjaxWebForms.js" />

        </Scripts>

    </telerik:RadScriptManager>

 

I get the following error (message in Spanish):

Detalles de error de página web

 

Agente de usuario: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; Media Center PC 6.0; .NET4.0C; InfoPath.2; .NET4.0E; .NET CLR 3.5.30729; .NET CLR 3.0.30729)

Fecha: Wed, 16 Feb 2011 10:56:33 UTC

 

Mensaje: Sys.WebForms.PageRequestManagerServerErrorException: Error de sintaxis en la expresión.

Línea: 934

Carácter: 13

Código: 0

URI: http://paellas.aw-dig.com/jsc/MicrosoftAjaxWebForms.debug.js

 

In short, basically always the same error!

In theory what I need is quite simple and basic, I just need to insert and eventually delete records from the RadGrid, as I described in my first post.
I do not know if the insert is well done because it is very "sui generis" (though apparently it does so without any problem) and maybe that's why then I cannot delete, I do not know!

 

Please help me to solve this problem. It is urgent!

Thanks for your help,

Jorge Saa-Gerbier

0
Jorge Saa-Gerbier
Top achievements
Rank 1
answered on 16 Feb 2011, 05:49 PM

Hello Radoslav,

  

I have found the problem, but not the solution!


To prove I change sds:SessionDataSource by asp:SqlDataSource and it works, I can delete from the RadGrid!

I use the file "SessionDataSource.cs" which I found on your website. I do not know if is the last version!

Please help me to solve this problem. It is urgent!

Thanks for your help,

Jorge Saa-Gerbier

 

0
Jorge Saa-Gerbier
Top achievements
Rank 1
answered on 17 Feb 2011, 11:56 AM

Hello Radoslav,

Trying to find a solution to my problem, I found a newer version of the file “SessionDataSource.cs”  In “RadControls for ASP.NET AJAX Q3 2010 SP2 Folder” in the subdirectory “Live Demos/App_Code” I replaced it and now I get a different message:

 


Detalles de error de página web

 Agente de usuario: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; Media Center PC 6.0; .NET4.0C; InfoPath.2; .NET4.0E; .NET CLR 3.5.30729; .NET CLR 3.0.30729)

Fecha: Wed, 16 Feb 2011 22:51:15 UTC

 

Mensaje: Sys.WebForms.PageRequestManagerServerErrorException: Referencia a objeto no establecida como instancia de un objeto.

Línea: 3

Carácter: 74672

Código: 0

URI: http://paellas.aw-dig.com/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl00_RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bAjaxControlToolkit%2c+Version%3d4.1.40412.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d28f01b0e84b6d53e%3aes-ES%3aacfc7575-cdee-46af-964f-5d85d9cdcf92%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%2c+Version%3d2010.3.1317.40%2c+Culture%3dneutral%2c+PublicKeyToken%3d121fae78165ba3d4%3aes-ES%3a9506cff2-3a86-46c5-b869-6ba1478f3c27%3a16e4e7cd%3aed16cbdc%3af7645509%3a24ee1bba%3a19620875%3a874f8ea2%3af46195d3%3a490a9d4e%3abd8f85e4%3a86526ba7%3a1e771326%3aaa288e2d%3a58366029

 


Thanks for your help,

Jorge Saa-Gerbier

0
Radoslav
Telerik team
answered on 18 Feb 2011, 08:17 AM
Hello Jorge,

It is hard to say what is causing the described issue without having the runnable application and debug it. Could you please elaborate a bit more on your scenario. When does the application show the exception -  when you start the application or when you try to delete record? Also which code block throws the exception? You could find out it by disabling the ajax of the application and run it in debug mode.

Also it will be helpful if you could send us a small runnable example which could be used for reproducing the unwanted behavior. You could open a formal support ticket from your Telerik account and attach a ZIP file there. Thus we will be able to gather more details about your scenario and to provide you a solution.
Looking forward for your reply.

Best wishes,
Radoslav
the Telerik team
Tags
Grid
Asked by
Jorge Saa-Gerbier
Top achievements
Rank 1
Answers by
Jorge Saa-Gerbier
Top achievements
Rank 1
Radoslav
Telerik team
Share this question
or