help in insert update and delete events in radgrid

2 posts, 0 answers
  1. Webster Velasco
    Webster Velasco avatar
    114 posts
    Member since:
    Jun 2012

    Posted 01 Dec 2009 Link to this post

    hi

    my insert delete and update events are not firing..

    i need help here is my code
    aspx that contain radgrid:
    <%@ Page Language="vb"MasterPageFile="Main.Master" AutoEventWireup="false" CodeBehind="UTEPagine.aspx.vb" Inherits="WebBIODemo.UTEPagine" %> 
      
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
     
    <asp:Content ID="Content1" ContentPlaceHolderID="cphMain" Runat="Server">  
      <div style="height:500px">  
          <telerik:RadScriptManager ID="RadScriptManager1" runat="server">  
          </telerik:RadScriptManager>  
     
        <!-- content start --> 
         
        <div> 
           <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"
                <script type="text/javascript"
                function ShowEditForm(id, rowIndex) 
                { 
                    var grid = $find("<%= grdUTEPagine.ClientID %>"); 
                     
                    var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element(); 
                    grid.get_masterTableView().selectItem(rowControl, true); 
                             
                    window.radopen("EditUTEPagineDemo.aspx?Id=" + id, "rwdUTEPagine"); 
                    return false; 
                } 
                function ShowInsertForm() 
                { 
                   window.radopen("EditUTEPagineDemo.aspx", "rwdUTEPagine"); 
                   return false; 
                } 
                function refreshGrid(arg) 
                { 
                 if(!arg) 
                 { 
                 $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");             
                    } 
                    else 
                    { 
                 $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate");             
                    } 
                } 
                function RowDblClick(sender, eventArgs) 
                { 
                 var param = eventArgs.getDataKeyValue("CODICELINGUA") + "|" + eventArgs.getDataKeyValue("CODICEFORM"); 
                 window.radopen("EditUTEPagineDemo.aspx?Id=" + param , "rwdUTEPagine"); 
                } 
                </script> 
            </telerik:RadCodeBlock> 
             
                <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"
                    <AjaxSettings> 
                        <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"
                            <UpdatedControls> 
                                <telerik:AjaxUpdatedControl ControlID="grdUTEPagine" /> 
                            </UpdatedControls> 
                        </telerik:AjaxSetting> 
                        <telerik:AjaxSetting AjaxControlID="grdUTEPagine"
                            <UpdatedControls> 
                                <telerik:AjaxUpdatedControl ControlID="grdUTEPagine" /> 
                            </UpdatedControls> 
                        </telerik:AjaxSetting> 
                    </AjaxSettings> 
                </telerik:RadAjaxManager> 
                <telerik:RadGrid 
                    OnItemCreated="grdUTEPagine_ItemCreated" 
                    ID="grdUTEPagine" 
                    runat="server" 
                    AllowPaging="True" 
                    AllowCustomPaging="True" 
                    AutoGenerateColumns="False"  
                    AllowSorting="True" 
                    PageSize="35" 
                    AllowFilteringByColumn="True"                  
                    Width="97%" 
                    DataSourceID="objDS"
                    <PagerStyle Mode="NumericPages" /> 
                    <MasterTableView 
                        AutoGenerateColumns="False" 
                        DataKeyNames="CODICELINGUA,CODICEFORM" 
                        ClientDataKeyNames="CODICELINGUA,CODICEFORM" 
                        Width="100%" 
                        CommandItemDisplay="Top" 
                        PageSize="15"
                        <Columns> 
                            <telerik:GridTemplateColumn UniqueName="EditRecord" AllowFiltering="False" Resizable="False">                            
                                <ItemTemplate> 
                                    <asp:HyperLink ID="EditLink" runat="server" Text="Edit"></asp:HyperLink> 
                                </ItemTemplate> 
                                <HeaderStyle Width="24px" /> 
                            </telerik:GridTemplateColumn> 
     
                               <telerik:GridBoundColumn DataField="CODICELINGUA" HeaderText="Codice Lingua" SortExpression="CODICELINGUA"  
                                    UniqueName="colCODICELINGUA" FilterImageToolTip="Filtro per Codice Lingua" Resizable="true">                                 
                                </telerik:GridBoundColumn>  
     
                               <telerik:GridBoundColumn DataField="DESCRIZIONE" HeaderText="Descrizione" SortExpression="DESCRIZIONE"  
                                    UniqueName="colDESCRIZIONE" FilterImageToolTip="Filtro per descrizione" Resizable="true">  
                                    <HeaderStyle Width="310px" />  
                                </telerik:GridBoundColumn>        
                                          
                                <telerik:GridBoundColumn DataField="DESCRIZIONEAIUTO" HeaderText="Descrizione AIUTO" SortExpression="DESCRIZIONEAIUTO"  
                                    UniqueName="colDESCRIZIONEAIUTO" FilterImageToolTip="Filtro per descrizione inglese" Resizable="true">  
                                    <HeaderStyle Width="310px" />  
                                </telerik:GridBoundColumn>                    
      
                                <telerik:GridBoundColumn DataField="ANNOTAZIONI" HeaderText="ANNOTAZIONI" SortExpression="ANNOTAZIONI"  
                                    UniqueName="colANNOTAZIONI" FilterImageToolTip="Filtro per descrizione inglese" Resizable="true">  
                                    <HeaderStyle Width="310px" />  
                                </telerik:GridBoundColumn>    
                                                         
                            <telerik:GridButtonColumn ConfirmText="Eliminare Utente Pagina?" ButtonType="ImageButton" ImageUrl="_img/Delete.gif" CommandName="Delete" Text="Elimina" UniqueName="colDelete"
                                <HeaderStyle Width="20px" /> 
                            </telerik:GridButtonColumn>  
     
                        </Columns> 
                        <CommandItemTemplate> 
                            <href="#" onclick="return ShowInsertForm();">Add New Record</a> 
                        </CommandItemTemplate> 
                    </MasterTableView> 
                    <ClientSettings> 
                        <Selecting AllowRowSelect="true" /> 
                        <ClientEvents OnRowDblClick="RowDblClick" /> 
                    </ClientSettings> 
                </telerik:RadGrid> 
                 
                <telerik:RadWindowManager ID="RadWindowManager1" runat="server"
                    <Windows> 
                        <telerik:RadWindow ID="rwdUTEPagine" runat="server" Title="Editing record" Height="400px" 
                            Width="500px" Left="150px" ReloadOnShow="true" ShowContentDuringLoad="false" Modal="true" /> 
                        <telerik:RadWindow runat="server" Title="WebBIO Zoom" Behaviors="none" Animation="FlyIn" DestroyOnClose="true"   
                    Left="" ID="rdwCodiceLingue"  NavigateUrl="Zoom.aspx" /> 
                    </Windows> 
                </telerik:RadWindowManager> 
        <asp:ObjectDataSource   
            ID="objDS"   
            runat="server"   
            SelectMethod="selectUTEPagine"       
            DeleteMethod="deleteUTEPagine"        
            SortParameterName="orderBy"  
            TypeName="GestioneLingue"  
            ConflictDetection="CompareAllValues"  
            OldValuesParameterFormatString="orig_{0}">  
            <SelectParameters>  
                <asp:ControlParameter ControlID="grdUTEPagine" Name="filterBy" PropertyName="MasterTableView.FilterExpression" Type="String" />  
            </SelectParameters>  
              
            <DeleteParameters>  
                <asp:Parameter Name="orig_CODICELINGUA" Type="String" />  
                <asp:Parameter Name="orig_CODICEFORM" Type="Int32" />  
            </DeleteParameters>  
              
        </asp:ObjectDataSource>         
          </div>  
      </div>  
    </asp:Content>  

    edit form:
    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="EditUTEPagineDemo.aspx.vb" Inherits="WebBIODemo.EditUTEPagineDemo" %> 
     
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     
    <html xmlns="http://www.w3.org/1999/xhtml" > 
    <head id="Head1" runat="server"
        <title>WebBIO Demo</title> 
        <link href="../_styles/main.css" type="text/css" rel="stylesheet" /> 
    </head> 
     
    <body style="margin:0px;height:100%;overflow:hidden" scroll="yes"
        <form id="EditUTEPagine" runat="server"  style="height:100%;margin:0px;" method="post"
       <script type="text/javascript"
            function CloseAndRebind(args) 
            { 
                GetRadWindow().Close(); 
                GetRadWindow().BrowserWindow.refreshGrid(args); 
            } 
             
            function GetRadWindow() 
            { 
                var oWindow = null
                if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog 
                else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;//IE (and Moz as well) 
                     
                return oWindow; 
            } 
     
            function CancelEdit() 
            { 
                GetRadWindow().Close();      
            } 
     
     
             function OpenWin(cod) 
                { 
                    var parentPage = GetRadWindow().BrowserWindow; 
                    var parentRadWindowManager = parentPage.GetRadWindowManager(); 
                    var oWnd2 = parentRadWindowManager.open("Zoom.aspx?KA=" + cod, "rdwCodiceLingue");   
                    window.setTimeout(function() 
                    { 
                        oWnd2.setActive(true);  
                    },0);                                               
                } 
             function getZoomValue(args) { 
                    alert(args); 
                    var arg = args.split("|") 
                    var QualeControllo;  
                    if (args[0] != null) {  
                        if (arg[0] == "CL"){ 
                            QualeControllo = document.getElementById("<%= txtCODICELINGUA.ClientID %>"); 
                        } 
                        else{ 
                            QualeControllo = document.getElementById("<%= txtCODICEFORM.ClientID %>"); 
                        } 
                        QualeControllo.value = arg[1];  
                    }  
                } 
        </script>      
        <div> 
          <asp:Label runat="server" ID="injectScript" Visible="true" Text="" ></asp:Label> 
          <asp:HiddenField runat="server" ID="lblIDtabella" Value="" /> 
          <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> 
          <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" /> 
          
     
          <table cellspacing="5" cellpadding="5" border="0" width="500px"
            <tr> 
                <th colspan="2"><asp:label ID="lblTitle" runat="server" /></th
            </tr> 
            <tr> 
                <td> 
                    <asp:Label ID="lblCODICELINGUA" Text="Codice Lingua:  " runat="server" /> 
     
                    <asp:ImageButton ID="cmdZOOMcodL" OnClientClick="OpenWin('CL'); return false;" runat="server"  ImageUrl="_img/lens.gif" /> 
                    <asp:textbox ID="txtCODICELINGUA"  runat="server" Enabled="false" MaxLength="4" /> 
                </td> 
                <td> 
                    <asp:label ID="lblCODICEFORM" Text="Codice Form:  " runat="server" /> 
     
                    <asp:ImageButton ID="cmdZOOMcodF" OnClientClick="OpenWin('CF'); return false;" runat="server" ImageUrl="_img/lens.gif" /> 
                    <asp:textbox ID="txtCODICEFORM" runat="server" Enabled="false" /> 
                </td>             
            </tr> 
            <tr> 
                <td> 
                    <asp:Label ID="lblDESCRIZIONE" Text="Descrizione: " runat="server" /> 
                </td> 
                <td> 
                    <asp:Label ID="lblDESCRIZIONEAIUTO" Text="Descrizione aiuto: " runat="server" /> 
                </td> 
                <td> 
                    <asp:Label ID="Label1" Text="Descrizione aiuto: " runat="server" /> 
                </td> 
            </tr> 
            <tr> 
                <td> 
                    <telerik:RadTextBox ID="rdtDESCRIZIONE" runat="server" TextMode="MultiLine" Width="220px" Height="90px" /> 
                </td>         
                <td> 
                    <telerik:RadTextBox ID="rdtDESCRIZIONEAIUTO" runat="server" TextMode="MultiLine" Width="220px" Height="90px" /> 
                </td> 
     
                <td> 
                    <telerik:RadTextBox ID="rdtANNOTAZIONI" runat="server" TextMode="MultiLine" Width="220px" Height="90px" /> 
                </td> 
            </tr> 
                <tr><td colspan="2" style="height:10px"></td></tr>                           
                <tr> 
                    <td> 
                        <asp:ValidationSummary ID="vsSummary" runat="server" Enabled="true" DisplayMode="BulletList" ShowSummary="false" ShowMessageBox="true" EnableClientScript="true" HeaderText="I seguenti campi devono essere valorizzati correttamente :"/> 
                    </td> 
                </tr> 
                <tr> 
                    <td colspan="2" style="text-align:right;"
                        <table cellpadding="0" cellspacing="10px" width="100%"
                            <tr> 
                                <td width="95%"></td> 
                                <td><asp:Button runat="server" id="btnSave" Text="Salva" OnClick="btnSave_Click" Width="80px"/></td> 
                                <td><button id="btnCancel" runat="server" onclick="closeRadWindow()" style="width:80px">Annulla</button></td
                            </tr> 
                        </table>                     
                    </td> 
                </tr> 
                <tr> 
                    <td colspan="2"><asp:Label runat="server" ID="lblErrorMsg" Text=""></asp:Label></td
                </tr>         
          </table> 
     
        </div> 
    </form> 
    </body> 
    </html> 

    code behind of edit
     
    Partial Public Class EditUTEPagineDemo 
        Inherits System.Web.UI.Page 
        Private m_wnd As Main 
     
        Dim id() As String 
        Dim param() As String 
        Dim paramVal() As String 
        Private clFunz As New WebBIODemo.Funzioni() 
     
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
            m_wnd = TryCast(Master, Main) 
            If Not IsPostBack Then 
                Dim idparam() As String 
                ReDim idparam(0 To 1) 
                idparam(0) = "CODICELINGUA" 
                idparam(1) = "CODICEFORM" 
                ' Determines if inserting or editing an existing prodotto 
                If Request.QueryString("ID") = Nothing Then 
                    ' New prodotto 
                    lblIDtabella.Value = "" 
                    lblTitle.Text = "Nuovo UTEPagine" 
                Else 
                    ' Determines if user is is valid 
                    cmdZOOMcodF.Visible = False 
                    cmdZOOMcodL.Visible = False 
                    Try 
                        lblIDtabella.Value = Request.QueryString("ID") 
                        id = Split(lblIDtabella.Value, "|") 
                        lblTitle.Text = "Modifica UTEPagine" 
     
                        ApriConnessioni() 
                        Call EseguiStored("UTEPagine_SelectInfoUP", idparam, id, kDataReader) 
                        With DR 
                            If .Read = True Then 
                                txtCODICELINGUA.Text = Nz(.GetValue(.GetOrdinal("CODICELINGUA")), "") 
                                txtCODICEFORM.Text = Nz(.GetValue(.GetOrdinal("CODICEFORM")), 0) 
                                rdtDESCRIZIONE.Text = Nz(.GetValue(.GetOrdinal("DESCRIZIONE")), "") 
                                rdtDESCRIZIONEAIUTO.Text = Nz(.GetValue(.GetOrdinal("DESCRIZIONEAIUTO")), "") 
                                rdtANNOTAZIONI.Text = (Nz(.GetValue(.GetOrdinal("ANNOTAZIONI")), "")) 
                            End If 
                            .Close() 
                        End With 
                        ChiudiConnessioni() 
     
                    Catch _err As Exception 
                        ' Bad format for prodotto id 
                        ' Assumes inserting a new prodotto 
                        lblIDtabella.Value = "" 
                        lblTitle.Text = "Nuovo UTEPagine" 
                    End Try 
                End If 
            End If 
        End Sub 
     
        Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) 
            ' Checks if user entered necessary data 
            If IsValid = True Then 
                If lblIDtabella.Value = "" Then 
                    ' Do insert 
     
                    Try 
                        'mettere l'esecuzione sp 
                        ApriConnessioni() 
                        ReDim param(0 To 6) 
                        ReDim paramVal(0 To 6) 
                        param(0) = "IDWS" 
                        paramVal(0) = IDWSname() 
                        param(1) = "NOTAMOD" 
                        paramVal(1) = "" 
                        param(2) = "CODICELINGUA" 
                        paramVal(2) = txtCODICELINGUA.Text 
                        param(3) = "CODICEFORM" 
                        paramVal(3) = txtCODICEFORM.Text 
                        param(4) = "DESCRIZIONE" 
                        paramVal(4) = rdtDESCRIZIONE.Text 
                        param(5) = "DESCRIZIONEAIUTO" 
                        paramVal(5) = rdtDESCRIZIONEAIUTO.Text 
                        param(6) = "ANNOTAZIONI" 
                        paramVal(6) = rdtANNOTAZIONI.Text 
     
                        EseguiStored("UTEPagine_Insert", param, paramVal, kAggiornaDati) 
     
                        ChiudiConnessioni() 
     
                        injectScript.Text = "<script type='text/javascript'>CloseAndRebind('insert')</script>" 
                    Catch _err As Exception 
                        ' Error during insertion 
                        ' TODO : Show Error Message 
                        lblErrorMsg.Text = "Errore durante ins. dati - " + _err.Source + "->" + _err.Message 
                    End Try 
                Else 
                    ' Do update 
     
                    Try 
                        'execution stored 
                        ApriConnessioni() 
     
                        ReDim param(0 To 6) 
                        ReDim paramVal(0 To 6) 
     
                        param(0) = "IDWS" 
                        paramVal(0) = IDWSname() 
                        param(1) = "NOTAMOD" 
                        paramVal(1) = "" 
                        param(2) = "CODICELINGUA" 
                        paramVal(2) = txtCODICELINGUA.Text 
                        param(3) = "CODICEFORM" 
                        paramVal(3) = txtCODICEFORM.Text 
                        param(4) = "DESCRIZIONE" 
                        paramVal(4) = rdtDESCRIZIONE.Text 
                        param(5) = "DESCRIZIONEAIUTO" 
                        paramVal(5) = rdtDESCRIZIONEAIUTO.Text 
                        param(6) = "ANNOTAZIONI" 
                        paramVal(6) = rdtANNOTAZIONI.Text 
     
                        EseguiStored("UTEPagine_Insert", param, paramVal, kAggiornaDati) 
     
                        ChiudiConnessioni() 
     
                        injectScript.Text = "<script type='text/javascript'>CloseAndRebind('update');</script>" 
     
                    Catch _err As Exception 
                        ' Error in updating  
                        ' TODO : Show Error Message 
                        lblErrorMsg.Text = "Errore durante agg. dati - " + _err.Source + "->" + _err.Message 
                    End Try 
                End If 
            End If 
        End Sub 
     
    End Class 



  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 02 Dec 2009 Link to this post

    Hello Webster,

    Try setting the Automatic operations for the grid to true. You can check out the following link for more informatio on Automatic operations:
    Automatic Operations

    Hope this helps..
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top