Can you please tell me if programatic databinding with manual CRUD handling is even possible with the WebDataGrid? I can honestly say I have never in my 15 years as a software developer come across a comercial product that had so many bugs in it or contained such poor functionality and event handling as this control. The only part of the editing core that seems to be handled accurately is the RowAdding behaviour. Every time I turn a corner I am faced with another bug and it is driving me crazy!
Even though I have turned all ViewState handling on the control off, it still seems to be caching data on the client even after a rebind. The delete I have coded on the ItemCommand event deletes the correct item from the database but after rebinding the refreshed data source, the client seems to rebind the previously requested datasource and for some reason drops the last record off and the one I deleted is still visible even though its not part of the new datasource. After a full refresh (Ctrl+F5) of the page this is immediatley evident.
As for the RowUpdating event, it doesn't get fired until another completely separate control on the page causes a full postback even though the RowUpdated event (which doesn't contain the row values) fires as soon as the selected row is changed. Is this a joke?! Please explain to me the rationalle behind this because I am baffled by it.
Next, if I try and add an AjaxControlToolkit ConfirmButtonExtender to a template column I get an error telling me that I have duplicate control id's after a postback.
These are obviously known problems as there are numerous posts about all the issues I have come across on this forum for which you fail to provide a valid solution. Can these problems be resolved or should I just get my money back?
-------------------------------------------------------------------------------------------------------------------------------------Markup : -------------------------------------------------------------------------------------------------------------------------------------
<asp:ScriptManager runat="server"></asp:ScriptManager> <span class="TitleText">TEST TEST TEST</span><br /><br />
<ig:WebDataGrid ID="grdClients" runat="server" EnableViewState="false" EnableAjaxViewState="false" EnableDataViewState="false" DataKeyFields="ClientId" StyleSetName="Office2007Black" Height="375px" Width="100%" AutoGenerateColumns="False" OnRowAdding="grdClients_RowAdding" OnRowUpdating="grdClients_RowUpdating" OnItemCommand="grdClients_ItemCommand"> <Columns> <ig:BoundDataField DataFieldName="ClientName" Key="ClientName"> <Header Text="Client"></Header> </ig:BoundDataField> <ig:TemplateDataField Key="Delete" Width="20px"> <ItemTemplate> <asp:ImageButton ID="btnDelete" runat="server" CommandArgument='<%# Eval("ClientId") %>' AlternateText="Delete" ImageUrl="~/images/btn_close2.png" /> </ItemTemplate> </ig:TemplateDataField> </Columns> <Behaviors> <ig:Activation Enabled="true" /> <ig:Sorting Enabled="true" /> <ig:ColumnResizing Enabled="true" /> <ig:EditingCore AutoCRUD="false" > <Behaviors> <ig:RowAdding> <EditModeActions MouseClick="Double" /> </ig:RowAdding> <ig:CellEditing> <CellEditingClientEvents ExitedEditMode="grdClients_ExitedEditMode"/> <EditModeActions MouseClick="Double" /> </ig:CellEditing> </Behaviors> </ig:EditingCore> </Behaviors> </ig:WebDataGrid>
-------------------------------------------------------------------------------------------------------------------------------------Codebehind :-------------------------------------------------------------------------------------------------------------------------------------
protected void Page_Load(object sender, EventArgs e) { this.InitialisePage(!Page.IsPostBack); }
public void InitialisePage(bool refresh) { if (refresh) { MPE.dOOdads.PayloadData.Clients clients = new MPE.dOOdads.PayloadData.Clients(HttpContext.Current.Server.MachineName, Common.Tools.GetApplicationDataBase());
clients.LoadAll();
this.grdClients.DataSource = clients.DefaultView.Table; this.grdClients.DataBind();
this.ViewState.Add("grdClients.DataSource", clients.DefaultView.Table); } else { this.grdClients.DataSource = this.ViewState["grdClients.DataSource"]; } }
protected void grdClients_ItemCommand(object sender, Infragistics.Web.UI.GridControls.HandleCommandEventArgs e) { try { MPE.dOOdads.PayloadData.Clients clients = new MPE.dOOdads.PayloadData.Clients(HttpContext.Current.Server.MachineName, Common.Tools.GetApplicationDataBase());
clients.LoadByPrimaryKey(int.Parse(e.CommandArgument.ToString())); clients.DeleteAll(); clients.Save();
this.InitialisePage(true); } catch { MPE.Common.Tools.MessageBox(this.Page, "Client is in use and cannot be deleted."); } }
protected void grdClients_RowAdding(object sender, Infragistics.Web.UI.GridControls.RowAddingEventArgs e) { MPE.dOOdads.PayloadData.Clients clients = new MPE.dOOdads.PayloadData.Clients(HttpContext.Current.Server.MachineName, Common.Tools.GetApplicationDataBase());
clients.AddNew(); clients.UserClientId = Common.Session.GetUserAccount().ClientId; clients.ClientName = e.Values["ClientName"].ToString(); clients.Save();
this.InitialisePage(true); }
protected void grdClients_RowUpdating(object sender, Infragistics.Web.UI.GridControls.RowUpdatingEventArgs e) { MPE.dOOdads.PayloadData.Clients clients = new MPE.dOOdads.PayloadData.Clients(HttpContext.Current.Server.MachineName, Common.Tools.GetApplicationDataBase());
clients.LoadByPrimaryKey((int)((object[])e.RowID["key"])[0]); clients.ClientName = e.Values["ClientName"].ToString(); clients.Save();
Hello Steve,
I apologize for the inconvenience you are having while using the product. The behavior you are experiencing doesn't sound right like the updating event not firing, while the updated event gets fired everytime you switch a row. Also, the viewstate disabled should not render any grid viewstate. There is also a 'dataviewstate' property, that holds the data. You may want to try out disabling that as well.
I would like to let you know that the support team are looking deeper into the issues, and will soon get in touch with you to provide proper resolution.
I request your patience while we try and help you out. You can also direct any other product concerns or suggestions directly to me at : murtazaa@infragistics.com
Best Regards,
Taz.
Steve,
I have looked into why you are getting the behavior that you are using the code that you have provided and I have attached a sample page that shows the desired behavior for Updating and Deleting.
For deleting, an additional line of code is needed in the ItemCommand event to clear the values that are loaded from the datasource before the call to InitialisePage. For this, add the following line of code before this call:
grdClients.ClearDataSource();
For editing the data, with Manual CRUD, the RowUpdating event should be used as the RowUpdated event will not fire. As far as the timing of RowUpdating, in my testing this was fired when I moved off of the row in the grid to another row. Is this behavior consistent with what you see?
Note that I changed the sample so that the DataSource for the WebDataGrid isn't stored in the ViewState of the page. This has been done because the ViewState of the page will not be updated during the AJAX calls for RowUpdating. While the state is sent from the client to the server it will not be sent back to the client and this can cause issues where updates would be lost because the DataSource that was saved on the last full post back would be used for later updates.
I still need to test the AjaxControlToolkit ConfirmButtonExtender and will send another update when I have done testing on this.
Let me know if you have any questions with this matter.
Hi Guys
Thank you for your responses but I've got to say, I am normally a very patient person but using this control has been the most disappointing and infuriating experience I have had while developing software in... well, ever.
Please note that all the problems described below were triggered using the example that you sent me in a raw page with nothing else on it at all. Also, Taz, you mentioned that I should have turned the DataViewState off, but if you have a look at the code I posted you would notice that it already was.
Now, in regard to your suggested solutions, at first it may seem that storing the DataSource in the Session instead of the ViewState and calling ClearDataSource() before a databind resolved the delete issue but after triggering multiple deletes, updates and additions in series, some very strange things started to happen. Most of the time the delete operation worked fine but on random occasions the ItemCommand event would not fire at all. After a sort, the wrong row would be deleted. The row in the selected position before the sort would be deleted instead the row selected position after the sort (obviously an indexing bug). On top of this, on occasions for no apparent reason I would get a page validation error (see attached).
Next, when the initially bound datasource is empty (eg zero rows) and you try and add a row to the grid, the Values property of the RowAddingEventArgs is empty. This can be replicated quite easily by creating but not pre populating the datasource in your provided example. And please don't tell me its because you didn't add the code to add the record to the datatable in the RowAdding event handler as I did this myself and the same problem still exists.
In regard to updating, why is the RowUpdating event only fired when the selected row is changed? What happens if there is only one row in the grid or the user navigates away from the page before changing the selected row? If it's because you can't determine when the user has finished updating every column in the row then why isn't there a CellUpdating event?
I have more but I'll save it for the next post.
For the issue with the Values collection being empty when binding to an Empty list, this is expected because view state is disabled for the grid so the Fields aren't being saved for the Fields collection. This gets used to build the hashtable for the Values collection and since the fields aren't being saved, null is found and the value doesn't get added to the Values list. There are two ways to correct this behavior:
Steve,Between your two posts, I see the following five points that need to be addressed:1. ConfirmButtonExtender causes duplicate id errors on a post back.2. Incorrect row is deleted because ItemCommand fires for the wrong row.3. ItemCommand isn't fired on some occasions.4. Page validation error occurs.5. RowUpdating doesn't contain the values when bound to an empty list.6. RowUpdating isn't fired when navigating away from the page.For the ConfirmButtonExtender I have updated the sample to use this with the ImageButton in the TemplateDataField. In my sample this works without issue when posting back in both the release (version 10.3.20103.1013) and latest service release (version 10.3.20103.2105) of NetAdvantage for ASP.NET 2010 Volume 3. Please test the attached sample page (ManualCRUDPage2.zip) and see if you have the same behavior as me and let me know the results.The issue with the incorrect row being deleted due to ItemCommand firing for the incorrect row is addressed in the latest service release and as such to resolve this issue you should get the latest service release from the My Keys and Downloads Page.For both the ItemCommand not firing on occasion and the page validation errors I wasn't able to reproduce either of this with my sample. If you can reproduce these with the attached sample page, please provide me with detailed steps on how to reproduce the behavior and I will test again. If you can't reproduce them with my sample, please provide me an example that does reproduce these.I was able to reproduce the behavior with e.Values being empty when bound to an empty DataTable and have logged this with development as development issue 69687. I have also provided more details on this through support case CAS-62466-NP67F5 which was created for this thread and is linked to development issue 69687.For RowUpdating not being fired when navigating away from the page, please provide details on how the navigation is being done when this issue occurs?Let me know if you have any questions with this matter.