User Profile & Activity

Maged Mikaeel Member
Page
of 6

Actually this is not what I'm looking for!!

I need to know  how to handle "BatchUpdating". There is NO example explains how to handle "BatchUpdatin" client API, like what parameters it takes ...etc


I need an example that shows how to handle and write client function to handle BatchUpdating.


For example we have this:


<ClientBindingSettings DataSourceType="WebService" ServiceUrl="../MembershipDataService.asmx"
        DataLoadMode="AllData" ItemTypeName="MembershipNote">
    <ServiceMethods SelectMethod="GetMembershipNotes" InsertMethod="InsertMembershipNote" />
    <ServiceEvents Selecting="Selecting_MembershipNotes"
                   Inserting="Inserting_Note"
                   Inserted="Inserted_GridData" Updating="Updating_GridData"/>
</ClientBindingSettings>




So I need to know how to implement Updating_GridData() function, I need a sample pls.

Maged

Also, I tried to change the col type to be text instead of checkbox, and it was displaying the true/false value correctly while the checkbox is always unchecked!!

Just to save time on this, the load function is getting the boolean value correctly (I traced it), and next is the GRID config:



<ISWebGrid:WebGrid ID="TransactionsWebGrid" runat="server" 
    DefaultStyleMode="Win7" Height="322px" UseDefaultStyle="True" Width="99%" BindingOperationMode="ClientBinding" >
    <LayoutSettings AllowColumnSizing="No" AllowContextMenu="False" AllowEdit="Yes" AllowSorting="Yes" AlwaysShowHelpButton="True"
        ColumnSetHeaders="Default" EditOnClick="True" FilterBarVisible="False" InProgressUIBehavior="ChangeCursorToHourGlass"
        RowHeaders="Default" ShowRefreshButton="True" AllowBatchUpdate="False" NewRowLostFocusAction="AlwaysUpdate" >
        <BatchUpdateSettings AllowReviewChanges="True" />
        <ClientSideEvents OnBatchUpdateSuccess="TransactionsWebGrid_OnBatchUpdateSuccess" />
    </LayoutSettings>
    <RootTable Caption="MembershipTransactions" DataKeyField="MembershipTransactionID" >
        <Columns>
            <ISWebGrid:WebGridColumn Caption="Date" DataMember="TransactionDate"
                EditType="NoEdit" Name="TransactionDate" Width="70px" 
                DataFormatString="d" DataType="System.DateTime">
                <HeaderStyle Cursor="Hand" Font-Italic="True" Font-Underline="True" HorizontalAlign="Center" />
            </ISWebGrid:WebGridColumn>
            
            <ISWebGrid:WebGridColumn Caption="Amount" DataMember="Amount" Name="Amount" 
                EditType="NoEdit" Width="55px" DataType="System.Decimal">
                <HeaderStyle Cursor="Hand" Font-Italic="True" Font-Underline="True" HorizontalAlign="Center" />
            </ISWebGrid:WebGridColumn>
            
            <ISWebGrid:WebGridColumn Caption="Cheque No" DataMember="ChequeNo" Name="ChequeNo" 
                EditType="NoEdit" Width="125px" DataType="System.Decimal">
                <HeaderStyle Cursor="Hand" Font-Italic="True" Font-Underline="True" HorizontalAlign="Center" />
            </ISWebGrid:WebGridColumn>
            
            <ISWebGrid:WebGridColumn Caption="Credit-Card No" DataMember="CreditCardNo" Name="CreditCardNo" 
                EditType="NoEdit" Width="125px" DataType="System.Decimal">
                <HeaderStyle Cursor="Hand" Font-Italic="True" Font-Underline="True" HorizontalAlign="Center" />
            </ISWebGrid:WebGridColumn>
            
            <ISWebGrid:WebGridColumn Name="Processed" Width="60px" Caption="Processed"
                DataMember="Processed" DataType="System.Boolean" EditType="Checkbox" ColumnType="CheckBox">
                
                <HeaderStyle Cursor="Hand" Font-Italic="True" Font-Underline="True" HorizontalAlign="Center" />
            </ISWebGrid:WebGridColumn>
            
            <ISWebGrid:WebGridColumn Caption="Process Date" CustomEditorName="VistaCalendar" 
                DataFormatString="d" DataMember="ProcessDate" DataType="System.DateTime" 
                EditType="Custom" Name="ProcessDate" Width="70px">
                <HeaderStyle Cursor="Hand" Font-Italic="True" Font-Underline="True" HorizontalAlign="Center" />
            </ISWebGrid:WebGridColumn>
            
            <ISWebGrid:WebGridColumn Caption="Reference" Name="ReferenceNo" Width="80px" DataMember="ReferenceNo">
                <HeaderStyle Cursor="Hand" Font-Italic="True" Font-Underline="True" HorizontalAlign="Center" />
            </ISWebGrid:WebGridColumn>
            
            <ISWebGrid:WebGridColumn Caption="Note" DataMember="Note" Name="Note" Width="95px">
                <HeaderStyle Cursor="Hand" Font-Italic="True" Font-Underline="True" HorizontalAlign="Center" />
            </ISWebGrid:WebGridColumn>
        </Columns>
    </RootTable>
    
    <ClientBindingSettings DataSourceType="WebService" ServiceUrl="../MembershipDataService.asmx"
                           ItemTypeName="MembershipTransaction" DataLoadMode="AllData">
        <ServiceMethods SelectMethod="GetMembershipTransactions" 
                        UpdateMethod="UpdateMembershipTransaction" />
        <ServiceEvents Selecting="Selecting_MembershipTransaction" Updating="Updating_MembershipTransaction" />
    </ClientBindingSettings>
    
</ISWebGrid:WebGrid>


This is really urgent, and I need your help ASAP.


Thanks,

Maged

You can do something like this, which works better too:

[WebMethod]    public object GetMembershipNotes(DataSourceSelectArguments selectArguments)
    {
        String[] strParameters = selectArguments.FilterExpression.Split(',');
        int nMembershipID = 0, nEntityTypeID = 0, nNoteType = 0;
        Int32.TryParse(strParameters[0], out nEntityTypeID);
        Int32.TryParse(strParameters[1], out nNoteType);
        Int32.TryParse(strParameters[2], out nMembershipID);
        
        ArrayList list = new ArrayList();
        foreach(Business.Note note in Business.NoteController.GetNotesForEntityAndNoteType(nEntityTypeID, nMembershipID, nNoteType) )
        {
            Note msNote         = new Note();
            msNote.NoteID       = note.NoteID;
            msNote.FullName     = note.User.LastName + ", " + note.User.FirstName;
            msNote.CreateDate   = note.CreateDate;
            msNote.Text         = note.Text;
            list.Add(msNote);
        }
        return list;
        throw new InvalidOperationException("Unsupported operation type!");
    }


On this example, I completely got the data from outside the LINQ and just stored it in list of LIN table.


For updates, you can do this:

[WebMethod]
    public TransactionResult UpdateMembershipCheque(MembershipCheque newObject, MembershipCheque originalObject)
    { 
        Business.MembershipCheque cheque = Business.MembershipChequeController.GetMembershipCheque(originalObject.MembershipChequeID); cheque.BatchNo = newObject.BatchNo; cheque.ChequeNo = newObject.ChequeNo; cheque.DepositDate = newObject.DepositDate; cheque.DueDate = newObject.DueDate; cheque.Save(); MembershipDataContext context = new MembershipDataContext(); return new TransactionResult() { OperationType = DataSourceOperation.Update, ReturnValue = true }; }


So you can build your classes and functions normally outside the LINQ schema, you on that case will need linq to exchange the data that you already collcted it.


I hope that will help you better.


Thanks,

Maged


I hope that works good for you too.

Thanks,

Maged

Hi Dave,

     I found so limitation on LINQ sql, so I decide to take different root.

     For example it doesn't support left join easily...etc

     So you can simply run your own SQL statements on different classes/functions and from there you can collect data from different tables on store it on LINQ table on extra fields you can create manually, so next is example of that:


[WebMethod]
    public object GetMembershipTransactions(DataSourceSelectArguments selectArguments)
    {
        MembershipDataContext context = new MembershipDataContext();
        context.DeferredLoadingEnabled = false;
        context.ObjectTrackingEnabled = false;
        int nMembershipID = 0;
        Int32.TryParse(selectArguments.FilterExpression, out nMembershipID);
        var MembershipTransactions = from membershipTransaction in context.MembershipTransactions
                                     where membershipTransaction.MembershipID == nMembershipID
                                       select new
                                       {
                                           MembershipTransactionID  = membershipTransaction.MembershipTransactionID,
                                           TransactionDate          = membershipTransaction.TransactionDate,
                                           Amount                   = membershipTransaction.Amount,
                                           ChequeNo                 = GetChequeNo(membershipTransaction.MembershipChequeID),
                                           CreditCardNo             = GetCreditCardInfo(membershipTransaction.CreditCardID),
                                           Processed                = membershipTransaction.Processed,
                                           ProcessDate              = membershipTransaction.ProcessDate,
                                           ReferenceNo              = membershipTransaction.ReferenceNo,
                                           Note                     = membershipTransaction.Note
                                       };
        return MembershipTransactions.ToList();
        throw new InvalidOperationException("Unsupported operation type!");
    }


As you can see, the credit card no and cheque no, I got them from different table and function without the hasle of LINQ sql statements.


Or you can even do something like this (even better:



Any update from any one from Intersoft support team?

We've a dead line to deliver this project and we need you help pls.


Maged

Hi Guys,

   I was not correct on my previous message about the root cause of this error.

 Now, I think I got it correct this time and I was able to even make it happen with the ClientBinding_BatchUpdate.aspx Intersoft sample.

 So, in the BugTrackerModel.designer.cs, if you define

namespace DataSet

{

.

.

.

}

That will make the error happen too.

In ClientBinding_BatchUpdate.aspx we have this function:

function Bug()
        {
            this.__type = "Bug";
            this.BugId = -1;
            this.Dupe = null;
            this.ChangeInLast = null;
            this.Component = null;
            this.Severity = null;
            this.OpSys = null;
            this.Target = null;
            this.Summary = null;
        }

So to make it work again, change it to:

function Bug()
        {
            this.__type = "DataSet.Bug";
            this.BugId = -1;
            this.Dupe = null;
            this.ChangeInLast = null;
            this.Component = null;
            this.Severity = null;
            this.OpSys = null;
            this.Target = null;
            this.Summary = null;
        }


That set!

Damn, three days to find out that!

I guess Intersoft need to change their sample to match this scenario!


Maged Mikaeel


Okay, fixed ......

So there is always work around to fix errors.

But I believe you guys at Intersoft need to do something to fix this issue from your side instead of the work around that I implemented!


So here is the fix:

1- My grid doesn't have all the fields from the table, as I don't need to display them all.

2- I have another fields from different tables displayed on the same grid.

3- The main issues is, you need to pass an object from the GRID to the update function, and that object has to match exactly the fields in the grid.

4- I created a table class in my data context with properties exactly the same as the fields in the grid.

5- I changed the update function to have the send parameter with the new created class instead of the original table class from the database.

6- I used the original class to save the data.

7- returned fake transaction result for success.


That stopped this error of happening.

I still believe that Intersoft need to fox that from the engine instead of creating fake classes like that.


Thanks,

Maged

That will not work, as the error is generated before we reach the update function it self, so I believe any change in the update function itself will not help, as the error still happening before we go there!

The zip file corupted, can you please resend and summarize the fix for us?

Thanks,

Maged

All times are GMT -5. The time now is 11:01 PM.
Previous Next