Grid won't refresh after perform work event

Posts   
 
    
dpanet
User
Posts: 14
Joined: 31-Oct-2006
# Posted on: 04-Apr-2007 07:13:05   

I made a grid INFRAGISTICS bound to LLBLGENDATASOURCE_2 , I added a template selector which lets choose which records to delete upfront and when the user click save changes, I should commit all the changes done to the grid, up to this point everything works fine, but the grid doesn't reflect the deleted records unless I hit the save button twice. this is my code

protected void LLBLGenProDataSource2_1_PerformWork(object sender, PerformWorkEventArgs2 e)
{

//this function adds selected deleted records to a Uow DeleteUsersFromCollection(); this.LLBLGenProDataSource2_1.UnitOfWorkObject.Commit(new DataAccessAdapter(), true); this.LLBLGenProDataSource2_1.Refetch = true;

}

protected void LLBLGenProDataSource2_1_PerformSelect(object sender, SD.LLBLGen.Pro.ORMSupportClasses.PerformSelectEventArgs2 e)
{
    this.LLBLGenProDataSource2_1.EntityCollection = ManageSystemSecurity.GetSystemUsers();

}
Aurelien avatar
Aurelien
Support Team
Posts: 162
Joined: 28-Jun-2006
# Posted on: 04-Apr-2007 09:54:16   

Hi,

the "unless I hit the save button twice." is odd, is the UoW well filled the first time you hit the save button ?

may you post the code ran on the save and in the DeleteUsersFromCollection() function ?

by the way, you can check this thread, witch is quite similar :

http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=8440&HighLight=1

dpanet
User
Posts: 14
Joined: 31-Oct-2006
# Posted on: 04-Apr-2007 23:06:53   

I added the ultrawebgrid.databind at the end of the event and now it is working, but I ran into another issue , If I enable paging to my grid, not the source control, and edited a cell in page 1 and decided to go to the next page without committing any chages, the webgrid would fire an excpetion like this

[NullReferenceException: Object reference not set to an instance of an object.] Infragistics.WebUI.UltraWebGrid.UltraWebGrid.UpdateDBRow(UltraGridRow row, UltraGridRow oldRow) +324 Infragistics.WebUI.UltraWebGrid.UltraWebGrid.ProcessChanges(StateChanges stateChanges, Boolean fireEvents) +1196 Infragistics.WebUI.UltraWebGrid.UltraWebGrid.RaisePostDataChangedEvent() +126 System.Web.UI.Page.RaiseChangedEvents() +137 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4778.

My web page should not commit any changes to the grid untill the save button is clicked.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 05-Apr-2007 12:14:04   

Would you please post the declarative code of the LLBLGenProDataSource and the Grid?

dpanet
User
Posts: 14
Joined: 31-Oct-2006
# Posted on: 05-Apr-2007 12:22:20   

Updatedbrow in the last stack called function updates the databound datasource with the new changed rows, but for some reason it is trying to access a nullified object somewhere inside that function. I don't do any update on the performwork event. In addition the paging is done from the webgrid, the datasource control paging is set to false.

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="ModifyUsers.aspx.cs" Inherits="ModifyUsers" Title="Untitled Page" %>

<%@ Register Assembly="SD.LLBLGen.Pro.ORMSupportClasses.NET20" Namespace="SD.LLBLGen.Pro.ORMSupportClasses" TagPrefix="llblgenpro" %>

<%@ Register Assembly="Infragistics2.WebUI.UltraWebGrid.v6.3, Version=6.3.20063.53, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" Namespace="Infragistics.WebUI.UltraWebGrid" TagPrefix="igtbl" %>

<%@ Register Assembly="Infragistics2.WebUI.Misc.v6.3, Version=6.3.20063.53, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" Namespace="Infragistics.WebUI.Misc" TagPrefix="igmisc" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <igmisc:WebPanel ID="WebPanel1" runat="server" Width="100%"> <Header Text="Modify Users"></Header> <Template>

<div class="div-padding"> <asp:P anel id="Panel1" runat="server" Width="70%" GroupingText="System Users"> <igtbl:ultrawebgrid id="UltraWebGrid1" runat="server" SkinID="GridEditWithoutScript" Height="200px" Width="325px" DataKeyField="SystemUserId" DataSourceID="LLBLGenProDataSource2_1" ><Bands> <igtbl:UltraGridBand DataKeyField="SystemUserId" Key="SystemUserID"> <AddNewRow View="NotSet" Visible="NotSet"></AddNewRow> <Columns> <igtbl:TemplatedColumn BaseColumnName="IsDirty" HeaderText="Delete User" Key="IsDirty" DataType="System.Boolean" Type="CheckBox"> <Header Caption="Delete User"> </Header> </igtbl:TemplatedColumn> <igtbl:UltraGridColumn BaseColumnName="SystemUserId" HeaderText="System User ID" Hidden="True" Key="SystemUserID" DataType="System.Int32"> <Header Caption="System User ID"> <RowLayoutColumnInfo OriginX="1" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="1" /> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn AllowUpdate="No" BaseColumnName="SystemUserUserName" HeaderText="System User Name" Key="SystemUserName"> <Header Caption="System User Name"> <RowLayoutColumnInfo OriginX="2" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="2" /> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn BaseColumnName="SystemUserIsAdministrator" DataType="System.Boolean" HeaderText="SystemUserIsAdministrator" IsBound="True" Key="SystemUserIsAdministrator" Type="CheckBox"> <Header Caption="SystemUserIsAdministrator"> <RowLayoutColumnInfo OriginX="3" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="3" /> </Footer> </igtbl:UltraGridColumn> </Columns> <RowEditTemplate> <br /> <p align="center"> <input id="igtbl_reOkBtn" onclick="igtbl_gRowEditButtonClick(event);" style="width: 50px" type="button" value="OK" />&nbsp; <input id="igtbl_reCancelBtn" onclick="igtbl_gRowEditButtonClick(event);" style="width: 50px" type="button" value="Cancel" /></p> </RowEditTemplate> <RowTemplateStyle BackColor="White" BorderColor="White" BorderStyle="Ridge"> <BorderDetails WidthBottom="3px" WidthLeft="3px" WidthRight="3px" WidthTop="3px" /> </RowTemplateStyle> </igtbl:UltraGridBand> </Bands> </igtbl:ultrawebgrid> <llblgenpro:LLBLGenProDataSource2 ID="LLBLGenProDataSource2_1" runat="server" AdapterTypeName="MPBS.DatabaseSpecific.DataAccessAdapter, MPBSDBSpecific" DataContainerType="EntityCollection" EntityFactoryTypeName="MPBS.FactoryClasses.SystemUsersEntityFactory, MPBS" LivePersistence="False" OnPerformSelect="LLBLGenProDataSource2_1_PerformSelect" > </llblgenpro:LLBLGenProDataSource2> <br /> </asp:P anel> <br /> <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/images/buttons/save-changes.gif" OnClick="ImageButton1_Click" /> <br /> </div>

</Template> </igmisc:WebPanel> </asp:Content>

dpanet
User
Posts: 14
Joined: 31-Oct-2006
# Posted on: 05-Apr-2007 12:25:46   

that is codebehind , nothing is done @ the page loading event

//This function loop through all checked items in the grid, build a filter and add A UOW for deletion for the selected users
    private void DeleteUsersFromCollection()
    {
        RelationPredicateBucket filter = new RelationPredicateBucket();
        ArrayList values = new ArrayList();
        bool found = false;
        foreach (UltraGridRow row in this.UltraWebGrid1.Rows)
        {

            if ((bool)row.GetCellValue(this.UltraWebGrid1.Columns[0]))
            {
                int employeeID = (int)row.GetCellValue(this.UltraWebGrid1.Columns[1]);

                values.Add(employeeID);
                found = true;

            }
        }
        if (found)
        {
            filter.PredicateExpression.Add(SystemUsersFields.SystemUserId== values);
            this.LLBLGenProDataSource2_1.UnitOfWorkObject.AddDeleteEntitiesDirectlyCall("SystemUsersEntity",filter );
        }
    }


//Commit changes if any are made after the user click the save button
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        if (this.LLBLGenProDataSource2_1.UnitOfWorkObject != null)
        {
            DeleteUsersFromCollection();
            this.LLBLGenProDataSource2_1.UnitOfWorkObject.Commit(new DataAccessAdapter(), true);
            this.LLBLGenProDataSource2_1.Refetch = true;
            this.UltraWebGrid1.DataBind();
        }
    }


    protected void LLBLGenProDataSource2_1_PerformSelect(object sender, SD.LLBLGen.Pro.ORMSupportClasses.PerformSelectEventArgs2 e)
    {
    
        this.LLBLGenProDataSource2_1.EntityCollection = ManageSystemSecurity.GetSystemUsers();
    
    }

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 05-Apr-2007 13:01:04   

Would you try and move the declaration of the LLBLGenProDataSource before that of the Grid that uses it?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39926
Joined: 17-Aug-2003
# Posted on: 05-Apr-2007 13:01:52   

PLease check your runtime lib version? It should be a version AFTER feb 19th, as the fix released on feb 19th wasnt complete.

Frans Bouma | Lead developer LLBLGen Pro
dpanet
User
Posts: 14
Joined: 31-Oct-2006
# Posted on: 07-Apr-2007 12:40:54   

I tried everything suggested , I'm on another machine and redid the whole steps I did in my previous machine + the suggestions, that same exception I get.

I have the March 21st version of LLBLGEN, I downloaded the new 7.1 Infragistics in hope that was the component to blame but no avail.

Edit:

After debugging, I noticed when updaing a cell in the grid, and changing the page index, the value of UOW is set to null , which means, that the datasource hasn't recognized the change of values to grid. I can't initilize this variable. and I don't how it recognize changes in the datagrid.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 09-Apr-2007 09:57:44   

After debugging, I noticed when updaing a cell in the grid, and changing the page index, the value of UOW is set to null , which means, that the datasource hasn't recognized the change of values to grid.

Maybe this has to do with the way you store the data between postbacks. Did you set the DataCacheLocation property of the LLBLGenProDataSource to "Session" or "ViewState"?

I tried everything suggested , I'm on another machine and redid the whole steps I did in my previous machine + the suggestions, that same exception I get.

I have the March 21st version of LLBLGEN, I downloaded the new 7.1 Infragistics in hope that was the component to blame but no avail.

mmm. strange, I'm clueless here. I have a feeling that it's an Infragistics issue, but to be certain, would you please try to reproduce this issue using the default MS GridView?