User Profile & Activity

Maged Mikaeel Member
Page
of 6

Hi,

  Thanks for your reply.

   1- I use incremental number for the key value.

   2- The main different between my code and your sample, is:

     on your sample you used this to create the record in the database:

    

    return provider.Insert(newObject);

    and you returned back the result, which I don't know what it has internally!


   on my code, I used this line of code to create the object.

  price.Save();

The save function will create a new record in the database and give me back the new generated record with the new key generated by the database engine.

Then I used this code to create the return object:

MembershipDataContext context = new MembershipDataContext();
        return new TransactionResult()
        {
            OperationType   = DataSourceOperation.Insert,
            ReturnValue     = true,
            AffectedResults = newObject.MembershipTypePriceID
        };

Now, how can I simulate or correctly create the return object that inform the grid with the new record key value?


Thanks,

Maged


Hi there,

   Just wondering when are you planning to post back the answer as I'm waiting for your answer/


Maged

Just to confirm it with you. You need to start with very empty grid that has no rows, and just add a new row and don't refresh, and then try to have a button that call a client side function that just display the grid TotalRows.

Please send me your sample to compare it with my code.

I can not send you my code as its large project that has many dependencies. But here is snapshot:

The grid definition:

<ISWebGrid:WebGrid ID="MembershipTypePricesWebGrid" runat="server" DefaultStyleMode="Win7" Height="340px"
UseDefaultStyle="True" Width="99%" BindingOperationMode="ClientBinding">

<LayoutSettings AllowEdit="Yes" AllowSorting="Yes" AlwaysShowHelpButton="False"
InProgressUIBehavior="ChangeCursorToHourGlass" RowHeaders="Default" ShowRefreshButton="True"
StatusBarVisible="True" TreeLines="False" AllowAddNew="Yes" EditOnClick="True"
AllowColumnSizing="No" AllowContextMenu="False" NewRowLostFocusAction="AlwaysPrompt">

<ClientSideEvents
OnBeginRowEditing="CheckNewRowsAddedToGrid"
OnBeforeRowSelect="CheckNewRowsAddedToGrid" />

<NewRowStyle BackColor="#FBF7AE" BackColor2="AliceBlue" BaseStyle="Active" Cursor="Text" Font-Italic="True" >
</NewRowStyle>
</LayoutSettings>

<RootTable Caption="MembershipTypeProduct" DataKeyField="MembershipTypePriceID">
<Columns>
<ISWebGrid:WebGridColumn Caption="Effective Date" DataMember="EffectiveDate"
Name="EffectiveDate" Width="240px" EditType="CalendarDropdown"
DataFormatString="d" DataType="System.Date">
<HeaderStyle Cursor="Hand" Font-Italic="True" Font-Underline="True" HorizontalAlign="Center" />
</ISWebGrid:WebGridColumn>

<ISWebGrid:WebGridColumn Caption="Member Category" DataMember="MemberCategoryName"
DataType="System.String" EditType="WebComboNET" Name="MemberCategoryName"
WebComboID="PricesMemberCategoryCombo" Width="240px">
<HeaderStyle Cursor="Hand" Font-Italic="True" Font-Underline="True" HorizontalAlign="Center" />
</ISWebGrid:WebGridColumn>

<ISWebGrid:WebGridColumn Caption="Member Charge" DataMember="MemberPrice" Name="MemberPrice" Width="240px">
<HeaderStyle Cursor="Hand" Font-Italic="True" Font-Underline="True" HorizontalAlign="Center" />
</ISWebGrid:WebGridColumn>

<ISWebGrid:WebGridColumn Caption="ID" DataMember="MembershipTypePriceID" Name="MembershipTypePriceID" Width="70px"
EditType="NoEdit" Visible="false">
<HeaderStyle Cursor="Hand" Font-Italic="True" Font-Underline="True" HorizontalAlign="Center" />
</ISWebGrid:WebGridColumn>
</Columns>
</RootTable>

<ClientBindingSettings DataSourceType="WebService" ServiceUrl="../MembershipDataService.asmx"
DataLoadMode="AllData" ItemTypeName="MembershipTypePrice" >
<ServiceMethods
SelectMethod="GetMembershipTypePrices"
UpdateMethod="UpdateMembershipTypePrices"
InsertMethod="InsertMembershipTypePrice" />
<ServiceEvents
Selecting="Selecting_MembershipTypeItem"
Updating="Updating_MembershipTypePrice"
Inserting="Inserting_MembershipTypePrice" />
</ClientBindingSettings>
</ISWebGrid:WebGrid>
</PageTemplate>
</ISWebDesktop:WebTabItem>


The function to calculate the total rows:

///
///
///
function CheckNewRowsAddedToGrid(controlId)
{
try
{
var grid = ISGetObject(controlId);

for (var i = 0; i < grid.TotalRows; i++)
{
var row = grid.RootTable.GetRow(i);
if(row.KeyValue < 1)
{
grid.Refresh();
return false;
}
}
}
catch (err)
{
alert("CheckNewRowsAddedToGrid: " + err.description);
}

return true;
}

Please try to replicate this code at your sample.

Thanks,

Maged

Thanks for your reply.

I already did this work around. But I still see this as a fatal bug, this behaviour is not the same with non client binding mode.

Its also not documented any where that we need to do that only on with the client side bidning!!

I think you didn't get my point here.

In your sample you have <ISWebGrid:WebGridColumn> for FirstName. Try to remove that Column from the grid, and your sample will not work as well. KEEP the DataKeyFielda as it is.

OR

Add on your database ItemID , then make it as your DataKeyField but do NOT add it as <ISWebGrid:WebGridColumn> at all

OR

On your sample, you can replace ClientBindingWebService.aspx code with the next code in order to replicate the issue easier:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ClientBindingWebService.aspx.cs"
Inherits="ClientBindingWebService" %>

<%@ Register Assembly="ISNet.WebUI.WebGrid" Namespace="ISNet.WebUI.WebGrid" TagPrefix="ISWebGrid" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function MyInfo()
{
this.FirstName = "";
this.LastName = "";
this.Age = "";
}

</script>
</head>
<body id="body" runat="server" leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0">
<form id="form1" runat="server">
<div>
<ISWebGrid:WebGrid ID="WebGrid1" runat="server" Height="250px" UseDefaultStyle="True"
Width="500px" BindingOperationMode="ClientBinding">
<LayoutSettings AllowAddNew="Yes" AllowDelete="Yes" AllowEdit="Yes">
</LayoutSettings>
<RootTable DataKeyField="FirstName">
<Columns>
<ISWebGrid:WebGridColumn Caption="Last Name" DataMember="LastName" Name="LastName"
Width="100px">
</ISWebGrid:WebGridColumn>
<ISWebGrid:WebGridColumn Caption="Age" DataMember="Age" Name="Age" Width="100px">
</ISWebGrid:WebGridColumn>
</Columns>
</RootTable>
<ClientBindingSettings DataSourceType="WebService" ServiceUrl="~/WebService.asmx"
ItemTypeName="MyInfo">
<ServiceMethods SelectMethod="GetMyInfo" DeleteMethod="DeleteMyInfo" InsertMethod="InsertMyInfo"
UpdateMethod="UpdateMyInfo"></ServiceMethods>
</ClientBindingSettings>
</ISWebGrid:WebGrid>
</div>
</form>
</body>
</html>



Maged

Hi,

With futher inverstigation, I think you still have the issue not fixed. And here is the root cause:

In your sample, you have this definition:


<RootTable DataKeyField="FirstName">

<ISWebGrid:WebGridColumn Caption="First Name" DataMember="FirstName" Name="FirstName"

Width="100px">

</ISWebGrid:WebGridColumn>


Ok, try to make small change on your sample, and the problem will apear right a way:

<RootTable DataKeyField="ItemID">

<ISWebGrid:WebGridColumn Caption="First Name" DataMember="FirstName" Name="FirstName"

Width="100px">

</ISWebGrid:WebGridColumn>


Now, on your WebGrid_ClientBinding.js , you have this code:
vbaa90.KeyValue =v18b39.Cells.GetNamedItem(vc2f92.DataKeyFields).Value;

This code will only work if you have at least one cell defined with the same name as the DataKeyField.


Again, on your sample if you just removed the first column (firstname), you will have the same issue I have.


Please, if you can send me the fix ASAP that will be great.


Thanks,

Maged

I followed all the steps, and still getting the same error!!

The about showing that, the version is: 7.0.7200.481

Well, this still the same, I still haveing the same issue!!

The update manager shows nothing to update stating that I'm up to date!

I uninstalled and reinstalled, and rerun update manager several times, and still getting the same result!
Is there any kind of cashing somewhere? Or how can I make sure that when I run my project, I have the latest version and assemblies on my bin directory?
What do you mean update
WebUI Framework?

Thanks,
Maged
All times are GMT -5. The time now is 1:06 AM.
Previous Next