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

ConfirmDialogType of RadWindow not deleting from grid or eds

7 Answers 153 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Marc
Top achievements
Rank 1
Marc asked on 26 Jan 2010, 12:57 AM
I have the following in my columns tag of my grid, however, nothing happens when I click ok in the confirm window.  The grid doesnt delete the row and the datasource doesnt either.  Is there something else needed to wire this up when using automatic CRUD and an entity datasource?

<telerik:GridButtonColumn CommandName="Delete" Text="Delete" ConfirmDialogType="RadWindow" ConfirmText="Delte this?" ConfirmTitle="Are you sure?" UniqueName= "DeleteColumn"></telerik:GridButtonColumn>

      <telerik:RadGrid ID="rgRequirements" runat="server" AllowAutomaticDeletes="True"  
            OnItemCommand="RadGrid1_ItemCommand" OnItemInserted="RadGrid1_ItemInserted" 
            AllowAutomaticInserts="True" AllowAutomaticUpdates="True"   
            AutoGenerateColumns="False" OnItemUpdated="RadGrid1_ItemUpdated" OnItemDeleted="RadGrid1_ItemDeleted" 
            DataSourceID="edsRequirement" GridLines="None" Width="550px"
        <MasterTableView AutoGenerateColumns="False" DataSourceID="edsRequirement" DataKeyNames="requirementID" EditMode="PopUp" CommandItemDisplay="Top"
            <RowIndicatorColumn> 
            <HeaderStyle Width="20px"></HeaderStyle> 
            </RowIndicatorColumn> 
            <ExpandCollapseColumn> 
            <HeaderStyle Width="20px"></HeaderStyle> 
            </ExpandCollapseColumn> 
            <commanditemsettings addnewrecordtext="Add new Requirement" /> 
             
            <Columns> 
                <telerik:GridBoundColumn DataField="requirement" HeaderText="Support Requirement"  ItemStyle-Width="300" SortExpression="requirement" UniqueName="requirement"
                    <ItemStyle Width="300px"></ItemStyle> 
                </telerik:GridBoundColumn> 
                <telerik:GridEditCommandColumn  ButtonType="LinkButton" EditText="Edit" HeaderStyle-Width="30" /> 
                <telerik:GridButtonColumn CommandName="Delete" Text="Delete" ConfirmDialogType="RadWindow" ConfirmText="Delte this?" ConfirmTitle="Are you sure?" UniqueName"DeleteColumn"></telerik:GridButtonColumn> 
            </Columns> 
             
            <EditFormSettings EditFormType="Template" InsertCaption="New Requirement" CaptionFormatString="Requirement"  
            PopUpSettings-Modal="true" PopUpSettings-Height="200"
                <FormTemplate> 
                <EditColumn UniqueName="EditCommandColumn1"></EditColumn> 
                <div class="formContent"
                        <telerik:RadTextBox runat="server" ID="tbCreated" Text='<%#Bind( "dateCreated") %>' Visible="false"></telerik:RadTextBox> 
                        <telerik:RadTextBox runat="server" ID="tbModified" Text='<%#Bind( "dateModified") %>' Visible="false"></telerik:RadTextBox>                         
                        Requirement: <cc1:HelpToolTip ID="HelpToolTip3" runat="server" HelpNode="Support Requirement"/><br />    
                           <telerik:RadTextBox runat="server" ID="requirement" Text='<%#Bind( "requirement") %>' 
                               Width="280px"  Rows="5" TextMode="MultiLine"/> 
                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator2" ControlToValidate="requirement"  Text="*" Display="Dynamic"/>     
                </div> 
                <div class="clear"/> 
                <div style="float:right;padding:10px;"
                    <asp:Button ID="Button1" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' 
                        runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'
                    </asp:Button>&nbsp; 
                    <asp:Button ID="Button2" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel"
                    </asp:Button>    
                </div>    
                <div class="clear"/> 
                </FormTemplate>    
            </EditFormSettings> 
             
        </MasterTableView> 
        <ClientSettings> 
            <ClientEvents OnPopUpShowing="PopUpShowing" /> 
        </ClientSettings>         
      </telerik:RadGrid> 
       
        <asp:EntityDataSource ID="edsRequirement" runat="server" 
            ConnectionString="name=LSTDev_Entities" DefaultContainerName="LSTDev_Entities"  
            EnableDelete="True" EnableInsert="True" EnableUpdate="True"  
            EntitySetName="FormsLDPRequirement"
        </asp:EntityDataSource> 

7 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 29 Jan 2010, 07:29 AM
Hello Marc,

I checked your code and I can confirm you have configured your grid and the DataSource control properly so the automatic operations should work as expected. You can try binding a Gridview with the preceding DataSource and see if the automatic operations work then in order to isolate the problem further.

Additionally, could you please specify what happens when you click on the delete button, and does the insert and update operations finish sucsessfully?

For more information on how to achieve atomatic CRUD operations with EntityDataSource, you can review the below online online resources:

http://www.telerik.com/help/aspnet-ajax/grdentityframeworkoperations.html
http://demos.telerik.com/aspnet-ajax/grid/examples/automaticoperations/efdatabinding/defaultcs.aspx

Sincerely yours,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Marc
Top achievements
Rank 1
answered on 19 Mar 2010, 11:07 PM
I attached my datasource to a GridView like you mentioned and the delete works fine there.  My data source's are all SQL DataSources now (as seen below) and I still have the same problem.

When I click the delete column I get a standard popup asking me if I want to delete.  I click ok, and the grid updates itself by removing the grid row.  However, upon reloading the page the row is back.  sqlDataSource_OnDeleting never gets fired.

Is there some other hook I have to add to wireup the grids delete command to the datasource delete command?

Page with the non working delete
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Assessments.aspx.cs" Inherits="LSTDeveloper.Site.Coach.Assessments" MasterPageFile="../Main.Master"%> 
 
 
<%@ Register Assembly="LSTDeveloper" Namespace="LSTDeveloper" TagPrefix="cc1" %> 
 
<asp:Content ID="Content2" runat="server" ContentPlaceHolderID="head"></asp:Content> 
 
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="phMain"
    <div class="contentSectionLeft"
        <h2>Assessments</h2> 
        <br /> 
        <asp:Button ID="Button1" runat="server" Text="Create A New Assessment" PostBackUrl="~/Site/Coach/AssessmentsView.aspx" /> 
        <br /> 
        <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowAutomaticDeletes="true" 
            AllowSorting="True" DataSourceID="sqlAssessments" GridLines="None"
<MasterTableView AutoGenerateColumns="False" DataSourceID="sqlAssessments"
<RowIndicatorColumn> 
<HeaderStyle Width="20px"></HeaderStyle> 
</RowIndicatorColumn> 
 
<ExpandCollapseColumn> 
<HeaderStyle Width="20px"></HeaderStyle> 
</ExpandCollapseColumn> 
    <Columns> 
<telerik:GridHyperLinkColumn DataNavigateUrlFields="assessmentKeyID" DataTextField="title" DataNavigateUrlFormatString="assessmentsView.aspx?id={0}&edit=true"></telerik:GridHyperLinkColumn> 
        <telerik:GridBoundColumn DataField="creatorName" DefaultInsertValue=""  
            HeaderText="Created By" SortExpression="creatorName" UniqueName="creatorName"
        </telerik:GridBoundColumn>       
        <telerik:GridBoundColumn DataField="dateCreated" DefaultInsertValue=""  
            HeaderText="Created Date" ReadOnly="True" SortExpression="dateCreated"  
            UniqueName="dateCreated"
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn DataField="dateModified" DefaultInsertValue=""  
            HeaderText="Modified Date" ReadOnly="True" SortExpression="dateModified"  
            UniqueName="dateModified"
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn DataField="dueDate" DataType="System.DateTime"  
            DefaultInsertValue="" HeaderText="Due Date" SortExpression="dueDate"  
            UniqueName="dueDate"
        </telerik:GridBoundColumn> 
        <telerik:GridClientDeleteColumn ButtonType="LinkButton" ConfirmText="Delete this Assessment?" ConfirmDialogType="Classic"  ConfirmTitle="Delete" HeaderStyle-Width="30" >               
               <HeaderStyle Width="30px"></HeaderStyle> 
        </telerik:GridClientDeleteColumn>         
    </Columns> 
</MasterTableView> 
<ClientSettings><ClientEvents OnPopUpShowing="PopUpShowing" /></ClientSettings>   
        </telerik:RadGrid> 
        <asp:SqlDataSource ID="sqlAssessments" runat="server"  OnDeleting="sqlDataSource_OnDeleting" 
            ConnectionString="<%$ ConnectionStrings:LSTDevConnectionString %>"  
            SelectCommand="AssessmentGetAll" SelectCommandType="StoredProcedure"  
            DeleteCommand="AssessmentDelete" DeleteCommandType="StoredProcedure"
            <DeleteParameters> 
                <asp:Parameter Name="assessmentKeyID" Type="Int32" /> 
            </DeleteParameters> 
        </asp:SqlDataSource> 
 
    </div> 
     
    <div class="clear"></div> 
</asp:Content> 
 

Code Behind for that page
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using LSTDeveloper.Code; 
 
namespace LSTDeveloper.Site.Coach 
    public partial class Assessments : SecurePage 
    { 
        protected void Page_Load(object sender, EventArgs e) 
        { 
 
        } 
 
        protected void sqlDataSource_OnDeleting(Object source, SqlDataSourceCommandEventArgs e) 
        { 
 
        } 
    } 
 

The masterpage
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Main.master.cs" Inherits="LSTDeveloper.Site.Main" %> 
<%@ Import Namespace="Telerik.Web.UI" %> 
<%@ Register src="../UserControls/SignOut.ascx" tagname="SignOut" tagprefix="uc1" %> 
 
<%@ Register src="../UserControls/SiteTagline.ascx" tagname="SiteTagline" tagprefix="uc3" %> 
<%@ Register src="../UserControls/Footer.ascx" tagname="Footer" tagprefix="uc4" %> 
<!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 runat="server"
    <title>LST Developer</title> 
    <link href="../styles.css" rel="stylesheet" type="text/css" /> 
    <script src="../../Scripts/Utilities.js" type="text/javascript"></script> 
    <asp:ContentPlaceHolder ID="head" runat="server"></asp:ContentPlaceHolder> 
    <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />      
</head> 
<body> 
 
<form id="form1" runat="server">            
  <div id="ContentArea"
        <asp:ScriptManager ID="ScriptManager1" runat="server" OnAsyncPostBackError="ScriptManager1_AsyncPostBackError" />         
         <uc3:SiteTagline ID="SiteTagline1" runat="server" />                
        <uc1:SignOut ID="SignOut1" runat="server" />   
        <telerik:RadAjaxManager runat="server" ID="RadAjaxManager1" DefaultLoadingPanelID="LoadingPanel1" EnableHistory="true" EnableAJAX="true"   > 
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="RadAjaxPanel1"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1" /> 
                    </UpdatedControls>         
                </telerik:AjaxSetting> 
             </AjaxSettings> 
        </telerik:RadAjaxManager> 
        <div id="NavigationMain" runat="server"><telerik:RadMenu ID="rmMain" Runat="server"></telerik:RadMenu></div
        <div id="NavigationSub" class="NavigationSub"><telerik:RadMenu ID="rmSub" Runat="server"></telerik:RadMenu></div
         
        <div class="content"
            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"  MinDisplayTime="500" Transparency="15" EnableSkinTransparency="false"></telerik:RadAjaxLoadingPanel>  
            <script type="text/javascript"
             //this is only used by pages doing file uploads, it must be before the RadAjaxPanel 
             function realPostBack(eventTarget, eventArgument) 
             { 
               __doPostBack(eventTarget, eventArgument); 
             } 
            </script >            
            <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" width="100%">      
                <div id="DotNetError"><div id="AlertMessage"></div></div>                      
                <asp:ContentPlaceHolder ID="phMain" runat="server" ></asp:ContentPlaceHolder> 
            </telerik:RadAjaxPanel> 
                        
        </div>             
         
    </div> 
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager> 
    <div id="ContentAreaFooter"><uc4:Footer ID="Footer1" runat="server" />     
  </div> 
</form>        
<script type="text/javascript" language="javascript"
    /* ZEE WAY TO TRAP ASYNC .NET 3.5 ERRORS */ 
    var divElem = 'DotNetError'
    var messageElem = 'AlertMessage'
    var errorMessageAdditional = '<b>An Error Has Occured</b><br><br>'
    var bodyTag = 'bodytag'
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler); 
    function ToggleAlertDiv(visString) { 
          var adiv = $get(divElem); 
        adiv.style.visibility = visString
 
    } 
    function EndRequestHandler(sender, args) { 
        if (args.get_error() != undefined && args.get_error().httpStatusCode == '500') { 
            var errorMessage = args.get_error().message + "<br><br>" + args.get_error().stack; 
            args.set_errorHandled(true); 
            ToggleAlertDiv('visible'); 
            $get(messageElem).innerHTML = errorMessageAdditional + errorMessage; 
        } 
 
    } 
</script>        
</body> 
</html> 
 

0
Iana Tsolova
Telerik team
answered on 24 Mar 2010, 04:02 PM
Hello Marc,

Try adding DataKeyNames to the MasterTableView as below and see if it makes any difference:

<MasterTableView DataKeyNames="assessmentKeyID" ....>

Additionally, you can handle the ItemDeleted event of the grid and see if any exception is thrown there.

Regards,
Iana
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Marc
Top achievements
Rank 1
answered on 27 Mar 2010, 12:15 AM
I added the datakeyname like you suggested. My breakpoints aren't hit for RadGrid1_OnItemDeleted and sqlDataSource_OnDeleting.

I also changed the delete column to not include the confirmation stuff and that didn't help.

Still at a loss here...


However...
Setting the following makes everything work just fine.  Is there something else I have to wire up to get the confirm prompt to actually work?

AutoGenerateDeleteColumn="true"
0
Iana Tsolova
Telerik team
answered on 31 Mar 2010, 02:07 PM
Hello Marc,

Please excuse me for misleading you. With the GridClientDeleteColumn the items are deleted on the client only. To delete them from database, you can do as in this demo.
Otherwise, you can use GridButtonColumn with CommandName set to Delete to delete the records in the database directly.

Check it out and let me know how it goes.

Greetings,
Iana
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Marc
Top achievements
Rank 1
answered on 02 Apr 2010, 10:53 PM
The demo you linked to doesnt work all the time.  It only works if I then cause another post back on that page after doing the delete.  If I simply leave the page and come back then the row isnt deleted.

Why is the client side delete wired into window.onunload?  Do you have a better way of triggering the js function?
0
Iana Tsolova
Telerik team
answered on 07 Apr 2010, 11:16 AM
Hi Marc,

The postback for items is invoked on window.onunload because it is fired when either postback is initiated from other control and or the page is closed.
However, you can implement your own logic for deleting the client-side deleted items from database.

Additionally, if you want to omit additional postbacks, you bind your grid client-side as in this demo.

Best wishes,
Iana
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Marc
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Marc
Top achievements
Rank 1
Share this question
or