iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Hi,
I've WebGrid that binds to the database as client side binding using web service.
I've allowed inserting new record. If the grid has no rows, and user trying to add the first row, it successfully add the new record in the database, but the grid got stock and keep saying at the status bar Add new row ... with wait cursor looping. User has to refresh the screen to exit this stuck!
If I've at least one row, this doesn't happen?
I really need you help in this issue ASAP.
This is the grid:
<ISWebGrid:WebGrid ID="EMRExamConfig_ChildExamsWebGrid" runat="server"
Height="100%" Width="100%" DefaultStyleMode="Elegant" UseDefaultStyle="True"
BindingOperationMode="ClientBinding" StateRestorationLevel="Low" ViewStateStorage="None">
<LayoutSettings AllowAddNew="Yes" AllowEdit="Yes" AllowSorting="Yes" AllowColumnSizing="No" AllowContextMenu="False"
AlwaysShowHelpButton="False" FilterBarVisible="False" AutoFitColumns="True" RowHeaders="No" TreeLines="False" AllowDelete="Yes">
</LayoutSettings>
<RootTable Caption="EMRMasterExam" DataKeyField="EMRExamID">
<Columns>
<ISWebGrid:WebGridColumn Caption="Mandatory" DataMember="IsMandatory" DataType="System.Boolean" Name="IsMandatory" EditType="Checkbox" Width="75px" ColumnType="CheckBox">
</ISWebGrid:WebGridColumn>
<ISWebGrid:WebGridColumn Caption="Name" DataMember="Name" Name="Name" Width="50px">
<ISWebGrid:WebGridColumn Caption="Normal Description" DataMember="NormalDescription" Name="NormalDescription" Width="150px">
</Columns>
</RootTable>
<ClientBindingSettings
DataLoadMode="AllData"
DataSourceType="WebService"
ItemTypeName="EMRExam"
ServiceUrl="../../../../../Data Set/CAEMRDataService.asmx">
<ServiceMethods
SelectMethod="GetChildEMRExam"
UpdateMethod="UpdateEMRExam"
DeleteMethod="DeleteEMRExam"
InsertMethod="InsertEMRExam" />
<ServiceEvents
Selecting="Selecting_ChildExam"
Updating="Updating_ChildExam"
Updated ="Updated_ChildExam"
Deleting="Deleting_ChildExam"
Deleted="Deleted_ChildExam"
Inserting="Inserting_ChildExam"
Inserted="Inserted_ChildExam" />
</ClientBindingSettings>
</ISWebGrid:WebGrid>
Thanks,
Maged
If the grid has no rows, and user trying to add the first row, it successfully add the new record in the database, but the grid got stock and keep saying at the status bar Add new row ... with wait cursor looping. User has to refresh the screen to exit this stuck!
WebGrid has a sample which similar to your scenario. The sample is: ClientBinding_Transactions.aspx. This sample uses service methods in App_Code/WebService.cs file.
In order to simulate the "grid has no rows" scenario, I made a minor modification to GetCustomers() method in WebService.cs by applying filter to Customers where its CompanyName starts with "Z". This is how GetCustomers look like after apply the filter:
[WebMethod] public List<Customer> GetCustomers() { NorthwindDataContext context = new NorthwindDataContext(); context.DeferredLoadingEnabled = false; context.ObjectTrackingEnabled = false; return context.Customers.Where(o => o.CompanyName.StartsWith("Z")).ToList(); }
Save the changes and view ClientBinding_Transactions.aspx sample file in browser. After loaded, WebGrid has no rows.
Next, I added a row. Unfortunately, I was unable to reproduce the reported problem. The grid didn't stuck.
For your information, I'm using WebGrid 9 build 1 and WebUI.NET Framework 3 build 913.
Should you find anything that I might miss during my attempt to reproduce the problem, please feel free to let me know. I'm willing to advise you further but in order to do so I would need you to elaborate on your specific scenario and possibly give me a running simple sample and step-by-step guide that I can use to observe the problematic behavior.
Thanks for your reply.
I reviewed your sample, and checked the differences between what I did and what is in the sample.
The main difference is you are using Customer table, and your primary key is CustomerID, what was the main difference is your primary keys is not Identity Increment. It’s actually a string that the user has to enter it.
In my case I have the key field as Identity Increment.
From my investigation, I found that the root cause for this issue, if you don't have the key field in the grid as one of the columns. So in my case I didn't have that because I don't need to display it, so the issue kept happening.
In order to work around it, I've to add a new column for the key field, and make it invisible which is not really convenient. This is really frustrating bug that cost me so much time to fix, please send it to your dev team if possible.
Maged Mikaeel
Thank you for the information about the identity increment.
I modified WebService.cs file in WebGrid samples ([WebGridSamples]\App_Code\WebService.cs) by adding following methods.
[WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ScriptService] public class WebService : System.Web.Services.WebService { public WebService() { //Uncomment the following line if using designed components //InitializeComponent(); } ... [WebMethod] public List<Shipper> GetShippers() { NorthwindDataContext context = new NorthwindDataContext(); context.DeferredLoadingEnabled = false; context.ObjectTrackingEnabled = false; return context.Shippers.ToList(); } [WebMethod] public TransactionResult UpdateShipper(Shipper newObject, Shipper originalObject) { NorthwindDataContext context = new NorthwindDataContext(); WebGridDataProvider<Shipper> provider = new WebGridDataProvider<Shipper>(context.Shippers.AsQueryable()); return provider.Update(newObject, originalObject); } [WebMethod] public TransactionResult InsertShipper(Shipper newObject) { NorthwindDataContext context = new NorthwindDataContext(); WebGridDataProvider<Shipper> provider = new WebGridDataProvider<Shipper>(context.Shippers.AsQueryable()); return provider.Insert(newObject); } [WebMethod] public TransactionResult DeleteShipper(Shipper originalObject) { NorthwindDataContext context = new NorthwindDataContext(); WebGridDataProvider<Shipper> provider = new WebGridDataProvider<Shipper>(context.Shippers.AsQueryable()); return provider.Delete(originalObject); } }
Next, I added WebGrid to a page.
<ISWebGrid:WebGrid ID="WebGrid1" runat="server" UseDefaultStyle="True" Height="300px" Width="400px" DefaultStyleMode="Elegant" BindingOperationMode="ClientBinding"> <LayoutSettings AllowColumnMove="Yes" AllowFilter="Yes" AllowGrouping="Yes" AllowSorting="Yes" GroupByBoxVisible="True" AutoFilterSuggestion="true" HeaderClickAction="SortMulti" AllowAddNew="Yes" AllowDelete="Yes" AllowEdit="Yes"> </LayoutSettings> <RootTable DataKeyField="ShipperID"> <Columns> <ISWebGrid:WebGridColumn Caption="ShipperID" DataMember="ShipperID" IsAutoIncrement="true" DataType="System.Int32" Name="ShipperID" Width="100px" Visible="false"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="CompanyName" DataMember="CompanyName" Name="CompanyName" Width="180px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Phone" DataMember="Phone" Name="Phone" Width="150px"> </ISWebGrid:WebGridColumn> </Columns> </RootTable> <ClientBindingSettings DataSourceType="WebService" ServiceUrl="~/WebService.asmx" ItemTypeName="Shipper"> <ServiceMethods SelectMethod="GetShippers" DeleteMethod="DeleteShipper" InsertMethod="InsertShipper" UpdateMethod="UpdateShipper" /> <ServiceEvents Inserting="Service_Inserting" /> </ClientBindingSettings> </ISWebGrid:WebGrid>
This WebGrid uses client-binding to WebService where ShipperID column is an identity increment column (its Visible property is set to false).
Object definition and Service_Inserting JavaScript functions are added. Object definition is required for data service transaction and Service_Inserting function is required to set the ShipperID object.
<script type="text/javascript"> // object definition is required for data service transactions // the object name should be identical to the value specified in ItemTypeName function Shipper() { this.ShipperID = -1; this.CompanyName = null; this.Phone = null; } function Service_Inserting(control, newObject, selectArguments) { newObject.ShipperID = parseInt("-1"); } </script>
Last, in order to simulate "the grid has no rows" scenario, I made a minor modification to GetShippers() method in WebService.cs by applying filter to Shippers where the CompanyName starts with "Z".
Save the changes and view the page sample file in browser. After loaded, WebGrid has no rows.
Feel free to let me know whether this sample is close enough to your scenario or not. If needed, I can enclose the files as attachment.
Hope this helps.
From your sample, if you remove this column from the grid, the issue will happen, please remove it first and repeat the test scenario again:
This is the column you need to remove:
<ISWebGrid:WebGridColumn Caption="ShipperID" DataMember="ShipperID" IsAutoIncrement="true" DataType="System.Int32" Name="ShipperID" Width="100px" Visible="false"> </ISWebGrid:WebGridColumn>
Thanks,Maged
Could you please try to use following technique and let me know whether this helps or not.
Step-by-step
The grid will look like following:
<ISWebGrid:WebGrid ID="WebGrid1" runat="server" UseDefaultStyle="True" Height="300px" Width="400px" DefaultStyleMode="Elegant" BindingOperationMode="ClientBinding"> <LayoutSettings ...> </LayoutSettings> <RootTable> <Columns> <ISWebGrid:WebGridColumn Caption="CompanyName" DataMember="CompanyName" Name="CompanyName" Width="180px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Phone" DataMember="Phone" Name="Phone" Width="150px"> </ISWebGrid:WebGridColumn> </Columns> </RootTable> <ClientBindingSettings DataSourceType="WebService" ServiceUrl="~/WebService.asmx" ItemTypeName="Shipper"> <ServiceMethods SelectMethod="GetShippers" DeleteMethod="DeleteShipper" InsertMethod="InsertShipper" UpdateMethod="UpdateShipper" /> <ServiceEvents Inserting="Service_Inserting" Updating="Service_Updating" /> </ClientBindingSettings> </ISWebGrid:WebGrid>
Save the changes and let me know whether this helps or not. I have tried row-editing and row-adding without problems in my local end.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname