Updating RadGrid data as part of a larger transaction

7 posts, 0 answers
  1. Cory Benjamin
    Cory Benjamin avatar
    18 posts
    Member since:
    Jul 2006

    Posted 15 Sep 2008 Link to this post

    Hi,

    We are using the RadGrid on pages that also contain other fields that will be updated to the database.  For example, we might have a page with textboxes and other controls to add/edit a master record, and then use the RadGrid to add/edit associated detail records.

    We want to update all of the detail records in the RadGrid at the same time that we update the master record, in a SQL transaction.

    Presently, we have the RadGrid data-bound to a LLBLGen datasource (although for this discussion I believe we can just assume that we are using a normal SQLDataSource).  As we add/update/delete records in the grid, they are being updated immediately in the datasource.

    Does anyone have any suggestions on how we can have all of the add/update/delete functionality in the grid take place internally (either client or server side), and then be mass-updated to the database when we are in our transaction to update the entire page?

    Thanks.
  2. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 18 Sep 2008 Link to this post

    Hello Cory Benjamin,

    In the most general case, this requirement can be implemented by binding RadGrid to a simple data table or other container controls. When any data source update is made, the actual data container gets updated. And finally, on a button click or other event, the actual SQL source can be updated with all the changes in the data table.

    Regards,
    Veli
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. jlehew
    jlehew avatar
    2 posts
    Member since:
    Jan 2007

    Posted 15 Oct 2008 Link to this post

    I'm trying to accomplish the same thing as Cory using the OnPerformWork event and the e.Uow.Commit method in LLBLGen v2.6 but am unable to get it to work.  It fires the OnPerformSelect event correctly but I can't get it to fire the OnPerformWork event in version 2008.2.1002.  I was able to get the GridView control to fire the event.

    I'm using the "Adapter" generated code vs. the "Self Servicing" code.  Look in the LLBLGen help under "Data Binding with ASP.NET 2.0" for the method I used to tie everything together. 
       
    1 using System;   
    2 using System.Collections.Generic;   
    3 using System.Linq;   
    4 using System.Web;   
    5 using System.Web.UI;   
    6 using System.Web.UI.WebControls;   
    7 using System.Data;   
    8 using System.Configuration;   
    9 using System.Web.Security;   
    10 using System.Web.UI.WebControls.WebParts;    
    11 using System.Web.UI.HtmlControls;   
    12  
    13 using SD.LLBLGen.Pro.ORMSupportClasses;   
    14 using ARMS.Data.DatabaseSpecific;   
    15  
    16 public partial class _Default : System.Web.UI.Page   
    17 {  
    18         protected void Page_Load(object sender, EventArgs e)   
    19         {  
    20         }  
    21  
    22  
    23         protected void DS_PerformGetDbCount(object sender, PerformGetDbCountEventArgs2 e)   
    24 {  
    25     using(DataAccessAdapter adapter = new DataAccessAdapter())   
    26     {  
    27         e.DbCount = adapter.GetDbCount(e.ContainedCollection, e.Filter);  
    28     }  
    29 }  
    30  
    31 protected void DS_PerformSelect(object sender, PerformSelectEventArgs2 e)   
    32 {  
    33     using(DataAccessAdapter adapter = new DataAccessAdapter())   
    34     {  
    35         adapter.FetchEntityCollection(e.ContainedCollection,   
    36         e.Filter,e.MaxNumberOfItemsToReturn, e.Sorter, e.PrefetchPath,   
    37         e.PageNumber, e.PageSize);  
    38     }  
    39 }  
    40  
    41 protected void DS_PerformWork(object sender, PerformWorkEventArgs2 e)   
    42 {  
    43     using(DataAccessAdapter adapter = new DataAccessAdapter())   
    44     {  
    45             e.Uow.Commit(adapter, true);   
    46      }  
    47 }  
    48 }  
    49  

     

    1 @ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>   
    2 <%@ Register Assembly="SD.LLBLGen.Pro.ORMSupportClasses.NET20" Namespace="SD.LLBLGen.Pro.ORMSupportClasses" TagPrefix="llblgenpro" %>   
    3 <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>   
    4 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
    5  
    6 <html xmlns="http://www.w3.org/1999/xhtml">   
    7 <head runat="server">   
    8 <title></title>   
    9 </head>   
    10 <body>   
    11 <form id="form1" runat="server">   
    12 <telerik:RadScriptManager ID="RadScriptManager1" runat="server">   
    13 </telerik:RadScriptManager>   
    14 <div>   
    15 <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">   
    16 </telerik:RadAjaxManager>   
    17 <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="75px" Width="75px">   
    18 <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>'   
    19 style="border: 0px;" />   
    20 </telerik:RadAjaxLoadingPanel>   
    21 </div>   
    22 <llblgenpro:LLBLGenProDataSource2 ID="LLBLGenProDataSource1" runat="server" AdapterTypeName="ARMS.Data.DatabaseSpecific.DataAccessAdapter, ARMS.DataDBSpecific"   
    23 DataContainerType="EntityCollection" LivePersistence="false" OnPerformSelect="DS_PerformSelect"   
    24 OnPerformGetDbCount="DS_PerformGetDbCount" OnPerformWork="DS_PerformWork"   
    25 EntityFactoryTypeName="ARMS.Data.FactoryClasses.LookupEntityFactory, ARMS.Data"   
    26 CacheLocation="Session" SortingMode="ClientSide">   
    27 <InsertParameters>   
    28 <asp:Parameter Name="LookupID" Type="Int32" />   
    29 <asp:Parameter Name="LookUpType" Type="String" />   
    30 <asp:Parameter Name="LookupTitle" Type="String" />   
    31 <asp:Parameter Name="LookupActiveYn" Type="String" />   
    32 <asp:Parameter Name="LookupAbbr" Type="String" />   
    33 <asp:Parameter Name="LookupShortTitle" Type="String" />   
    34 </InsertParameters>   
    35 <UpdateParameters>   
    36 <asp:Parameter Name="LookupId" Type="Int32" />   
    37 <asp:Parameter Name="LookUpType" Type="String" />   
    38 <asp:Parameter Name="LookupTitle" Type="String" />   
    39 <asp:Parameter Name="LookupActiveYn" Type="String" />   
    40 <asp:Parameter Name="LookupAbbr" Type="String" />   
    41 <asp:Parameter Name="LookupShortTitle" Type="String" />   
    42 </UpdateParameters>   
    43  
    44 </llblgenpro:LLBLGenProDataSource2>   
    45 <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True" EnableLinqExpressions="false"   
    46 PageSize="3" AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True" DataSourceID="LLBLGenProDataSource1"   
    47 GridLines="None" DataMember="DefaultView">   
    48 <MasterTableView DataSourceID="LLBLGenProDataSource1" AllowAutomaticDeletes="true"   
    49 AllowAutomaticInserts="true" AllowAutomaticUpdates="true" DataKeyNames="LookupID"   
    50 DataMember="DefaultView" AdditionalDataFieldNames="LookUpType, LookupTitle, LookupActiveYn, LookupAbbr, LookupShortTitle">   
    51 <RowIndicatorColumn>   
    52 <HeaderStyle Width="20px"></HeaderStyle>   
    53 </RowIndicatorColumn>   
    54 <ExpandCollapseColumn>   
    55 <HeaderStyle Width="20px"></HeaderStyle>   
    56 </ExpandCollapseColumn>   
    57 </MasterTableView>   
    58 <FilterMenu EnableTheming="True">   
    59 <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>   
    60 </FilterMenu>   
    61 </telerik:RadGrid>   
    62 <br>   
    63 <br>   
    64 <br>   
    65 <asp:GridView ID="GridView1" runat="server" DataSourceID="LLBLGenProDataSource1"   
    66 DataKeyNames="LookupId" AllowPaging="True" PageSize="3" AutoGenerateColumns="False"   
    67 AutoGenerateDeleteButton="True" AutoGenerateEditButton="True">   
    68 <Columns>   
    69 <asp:BoundField DataField="LookupId" HeaderText="LookupId" ReadOnly="True" SortExpression="LookupId" />   
    70 <asp:BoundField DataField="LookUpType" HeaderText="LookUpType" SortExpression="LookUpType" />   
    71 <asp:BoundField DataField="LookupTitle" HeaderText="LookupTitle" SortExpression="LookupTitle" />   
    72 <asp:BoundField DataField="LookupActiveYn" HeaderText="LookupActiveYn" SortExpression="LookupActiveYn" />   
    73 <asp:BoundField DataField="LookupAbbr" HeaderText="LookupAbbr" SortExpression="LookupAbbr" />   
    74 <asp:BoundField DataField="LookupShortTitle" HeaderText="LookupShortTitle" SortExpression="LookupShortTitle" />   
    75 </Columns>   
    76 </asp:GridView>   
    77 </form>   
    78 </body>   
    79 </html> 

    Cory, if you would put up some sample code that would be great.  

    Thanks,
    John



     

  5. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 17 Oct 2008 Link to this post

    Hi,

    Unfortunately I was unable to reproduce the behavior you are describing. I have attached a simple project with which I'm testing. Please take a look, maybe I'm missing something obvious.

    Sincerely yours,
    Rosen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. jlehew
    jlehew avatar
    10 posts
    Member since:
    Oct 2008

    Posted 12 Dec 2008 Link to this post

    I was able to get your sample app to run and after reviewing it, I should have clarified this in my previous post... 

    Clicking Update calls the PerformWork method correctly, but if AutoGenerateDeleteColumn="true" is added to this sample app, clicking the Delete shortcut it does not call PerformWork.  The asp:GridView does call it when Deleting is clicked but the RadGrid doesn't.

    Running version 2008.3.1105.

    Thanks,
    John
  7. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 15 Dec 2008 Link to this post

    Hello,

    Can you please check if you have AllowAutomaticDeletes option set to true? More information about automatic operation can be found in our help documentation here.

    Best wishes,
    Rosen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  8. jlehew
    jlehew avatar
    10 posts
    Member since:
    Oct 2008

    Posted 19 Dec 2008 Link to this post

    That was it.  Once I added that property it worked. 

    Thanks,
    John
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017